Comp 170 Lab 8 - DoME (Database of Multimedia Entertainment), March 22

The DoME program is the central example of chapter 8; it is a simple database for a combined library of videos and CDs. You can create entries of either type, and print them out (CDs first, then Videos).

The version you are to work with is here. You are to add the following features:

The Book class should have the following fields: title, author, gotIt, comment. Create an appropriate constructor, setComment & getComment, setOwn & getOwn, getTitle, and print.

To create the Book class, click on the New Class... button, cut out the contents of the template BlueJ suggests for the contents, paste in the contents of the Video or CD class, and then edit appropriately.

To allow books to be contained in the database, add an ArrayList field books, a method addBook, and adjust list so that books are listed after CDs and Videos.

To search the items for a given string srchkey, use the contains(String s) method of the String class:

     title = video.getTitle();	// or book or cd
     if (title.contains(srchkey))
It is much better if you do the search in a case-insensitive way. To do that, you have to convert both the title and srchkey to, say, lower case:
     title = title.toLowerCase();
     srchkey = srchkey.toLowerCase();
Does this change the title permanently? Change srchkey to lower case only once, at the beginning, not once each time through the loop!

Model your search loops (three of them, one each for CDs, Videos, and Books) after the loops in list. Actually, list is just a special case of search where you're searching for the empty string: every title contains that and thus every item will print.

Email me your completed Database.java and Book.java files.