Software Development (CSC 321 2016F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [Teaching & Learning]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Outlines]
Reference: [Slack] [Ruby@CodeCademy]
Related Courses: [Rails Tutorial] [CSC 321 2016S @ EdX] [CSC 321 2015S (Davis)] [CSC 321 2016S (Rebelsky)] [CSC 322 2016F (Rebelsky)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker]
Overview
Notes
Homework
Good Things To Do
Note
What's something familiar?
What's something new and exciting you've discovered about Ruby?
How does Ruby handle a programmer's need for multiple inheritance?
How do we deal with multiple inheritance in Java?
However, Java does support implementing multiple interfaces, which means that you can use an object in multiple situations
public interface BaseballPlayer { public void hit(Baseball ball); } // interface BaseballPlayer
public interface ComputerScientist { public void code(Specification problem); }
public interface Physicist { }
public class NT implements BaseballPlayer, ComputerScientist, Physicist { public void hit(Baseball ball) { System.out.println("Home run!"); } // hit
public void code(Specification problem) { System.out.println("int main(return 0);"); } // code }
...
solveAllTheWorldsProblems(ComputerScientist cs) { for (problem : Problems) { compile(cs.code(problem)).execute(); } }
adam = new NT(); solveAllTheWorldsProblems(adam);
Java does not allow multiple inheritance because it leads to some significant semantic problems. For example, what happens if two parents have the same method?
What is something particularly confusing or puzzling in the Codecademy tutorial?
Other comments ...
Write sums_to_n?(vals,val) that returns true if any two distinct
values from vals (a list of values) sums to val.
sums_to_n?([1,2,7],5) -> falsesums_to_n?([1,2,7],3) -> truesums_to_n?([1,2,7],8) -> truesums_to_n?([1,2,7],9) -> trueTwo nested .each loops
vals.each {|x| vals.each {|y| if (x+y) == val return true;}}
return false;
Doesn't work for distinct
[4,1,2].sort.combination(2).each{|x,y| print x,y}Write multiple_of_4?(bitstring) that takes a string of 0's and 1's
(representing an unsigned integer) as input and returns true if the
string represents an integer divisible by four.
Write starts_with_consonant?(str) that determines if a string
starts with a consonant.