
















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















































public void setComment(String com) { comment = com; }
public String getComment() { return comment; }
public void setOwn(boolean ownIt) // set the flag indicating whether we own this CD. { gotIt = ownIt; }
public boolean getOwn() // return true if we own a copy of this CD. { return gotIt; }
public void print() // print details about this CD { System.out.print("CD: " + title + " (" + playingTime + " mins)"); if (gotIt) System.out.println("*"); else System.out.println(); System.out.println(" " + artist); System.out.println(" tracks: " + numberOfTracks); if (comment != null) System.out.println(" " + comment); } // end of print()
} // end of CD class
public void setComment(String com)
{ comment = com; }
public String getComment()
{ return comment; }
public void setOwn(boolean ownIt)
// set the flag indicating whether we own this DVD.
{ gotIt = ownIt; }
public boolean getOwn()
// return true if we own a copy of this DVD.
{ return gotIt; }
public void print() // print details about this DVD { System.out.print("DVD: " + title + " (" + playingTime + " mins)"); if (gotIt) System.out.println("*"); else System.out.println(); System.out.println(" " + director); if (comment != null) System.out.println(" " + comment); } // end of print()
} // end of DVD class
public void list() // print a list of all currently stored CDs and DVDs { for (CD cd : cds) cd.print();
for (DVD dvd : dvds) dvd.print(); } // end of list()
} // end of Database class
public class UseDome
{
public static void main(String[] args) { Database db = new Database();
CD beatles = new CD("the white album", "the beatles",13, 122); db.addCD( beatles); beatles.setComment("the best of the later period");
db.addCD( new CD("morrison hotel", "the doors", 11, 109)); db.addCD( new CD("dark side of the moon","pink floyd",9,100)); :