1  public class MainCDCollection{
 2
 3    public static void main(String[] args){
 4
 5      CD pFloyd = new CD("Wish you were here", "Pink Floyd", 1975, 5);
 6      pFloyd.addSong("Shine on you crazy diamond");
 7      pFloyd.addSong("Welcome to the machine");
 8      pFloyd.addSong("Have a cigar");
 9      pFloyd.addSong("Wish you were here");
10      pFloyd.addSong("Shine on you crazy diamond (version 2)");
11
12      CD rhead = new CD("OK Computer", "Radiohead", 1997, 12);
13      rhead.addSong("Airbag");
14      rhead.addSong("Paranoid Android");
15      rhead.addSong("Subterranean Homesick Alien");
16      rhead.addSong("Exit Music (For A Film)");
17      rhead.addSong("Let Down");
18      rhead.addSong("Karma Police");
19      rhead.addSong("Fitter Happier");
20      rhead.addSong("Electioneering");
21      rhead.addSong("Climbing Up The Walls");
22      rhead.addSong("No Surprises");
23      rhead.addSong("Lucky");
24      rhead.addSong("Tourist, The");
25
26      CD nCave = new CD("Let Love In", "Nick Cave and the bad seeds", 1996, 10);
27      nCave.addSong("Do You Love Me?");
28      nCave.addSong("Nobody's Baby Now");
29      nCave.addSong("Loverman");
30      nCave.addSong("Jangling Jack");
31      nCave.addSong("Red Right Hand");
32      nCave.addSong("I Let Love In");
33      nCave.addSong("Thirsty Dog");
34      nCave.addSong("Ain't Gonna Rain Anymore");
35      nCave.addSong("Lay Me Low");
36      nCave.addSong("Do You Love Me? (Part 2)");
37
38      // identical to nCave above
39      CD nCave2 = new CD("Let Love In", "Nick Cave and the bad seeds", 1996, 10);
40      nCave2.addSong("Do You Love Me?");
41      nCave2.addSong("Nobody's Baby Now");
42      nCave2.addSong("Loverman");
43      nCave2.addSong("Jangling Jack");
44      nCave2.addSong("Red Right Hand");
45      nCave2.addSong("I Let Love In");
46      nCave2.addSong("Thirsty Dog");
47      nCave2.addSong("Ain't Gonna Rain Anymore");
48      nCave2.addSong("Lay Me Low");
49      nCave2.addSong("Do You Love Me? (Part 2)");
50
51
52
53      CDCollection myCDs = new CDCollection(4);
54      boolean pFloydTest =myCDs.addCD(pFloyd);
55      boolean rheadTest =myCDs.addCD(rhead);
56      boolean nCaveTest = myCDs.addCD(nCave);
57      System.out.println(" Added Pink Floyd? "+ pFloydTest);
58      System.out.println(" Added Radiohead? "+ rheadTest);
59      System.out.println(" Added Nick Cave? "+ nCaveTest);
60      myCDs.showInfo();
61      boolean nCave2Test = myCDs.addCD(nCave2); //This should fail 
62      boolean rhead2Test = myCDs.addCD(rhead);  //This should fail 
63      System.out.println(" Added Radiohead 2? "+ rhead2Test);
64      System.out.println(" Added Nick Cave 2? "+ nCave2Test);
65      myCDs.showInfo();    //same output as 2 lines above
66
67    }
68  }

Generated with vim2html
Copyright © 2003-2004 by Chip Cuccio <http://norlug.org/~chipster/finger>