![]() |
![]() |
|
home—info—archive—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
int ssf = 0; for ( int i = 2; i < 10; i = i+3 ) { int ssf = 0; ssf = ssf + i; System.out.println( "i=" + i + "; ssf=" + ssf ); i = i + 3; } |
In the following diagram, boxes indicate classes (types), and arrows represent “has-a”. For example, Every Lab has a Robot, every Robot has a Blender, etc.. If you have a particular object (say, a BioLab, which is of type Lab), it therefore makes sense to talk about the “BioLab's Robot” and even the “BioLab's Robot's Blender”, etc..
Add to your class PlayList by writing the method numCoversOn, which takes in a single list of songs and returns how many Songs on the second list are cover versions of a song on the first. Alternately, you can have the method just take two LinkedList<Song>s.
/* A method inside class PlayList: */ /** Return how many songs on a List<Song>s are * cover versions of something in this PlayList. * (Note that a song might count several times, if it is a cover version * of several songs on this PlayList.) * @param somesongs The list of songs to check for covers of. [If using this alternate approach) * @param othersongs The list of songs to look for covers on. * @return how many songs on othersongs are a cover version of * something on this Playlist. */ int numCoversOn( LinkedList<Song> othersongs ) // or... static int numCoversOn( LinkedList<Song> somesongs, LinkedList<Song> othersongs ) |
Hint: Call one of your methods from hw10, as a helper.
Write a method songsInCommon which returns all Songs which appear on two different PlayLists. (That is, all songs which are equals, and not merely cover versions.)
Hints:
home—info—archive—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2008, Ian Barland, Radford University Last modified 2008.Apr.23 (Wed) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |