Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- /**
- * Class to test CD implementation
- *
- * @author marc/murray
- * @version December 2004/2007
- */
- public class CDTester
- {
- public void test()
- {
- CD mycd = new CD("Van Morrison", "Astral Weeks", 4);
- // add some tracks
- mycd.addTrack(1, new Track("Slim Slow Rider", 423));
- mycd.addTrack(2, new Track("Astral Weeks", 320));
- mycd.addTrack(3, new Track("Young Lovers Do", 276));
- mycd.addTrack(4, new Track("Ballerina", 365));
- // find out total
- System.out.println("Total running time is " + mycd.totalRunningTime());
- // Result should be Total running time is 23:04
- // find longest track
- System.out.println("Track with longest running time is " + mycd.longestTrack());
- // Result should be Track with longest running time is Slim Slow Rider
- CD myothercd = new CD("Teenange Fanclub", "Thirteen", 1);
- myothercd.addTrack(1, new Track("Fear of Flying", 324));
- System.out.println("Total running time is " + myothercd.totalRunningTime());
- // Result should be Total running time is 5:24
- // find longest track
- System.out.println("Track with longest running time is " + myothercd.longestTrack());
- // Result should be Track with longest running time is Fear of Flying
- // challenge exercise - find tracks
- /* Remove these comments to test these if you have attempted it
- System.out.println("Track with 'er' are :");
- ArrayList <String> tracks = mycd.findTracks("er");
- for (String s : tracks) {
- System.out.println(s);
- }
- */
- /* Result should be:
- Track with 'er' are :
- Slim Slow Rider
- Young Lovers Do
- Ballerina
- */
- }
- }
Add Comment
Please, Sign In to add comment