CIS 67: Homework 12

Handed out: 04/10/07
Due: by Noon on 04/16/07
Email program to TA

CIS67: Homework 12

We will build a repository of information about CDs. Here are the attributes of a CD: uniqueId, title, artist, cost, haveIt, comment. The information about CDs is kept in a file. The order of the items in the file is up to you. A number of successive lines in the file are used to represent an item. Each line is of the form attributename value. An example of possible item file is here. Notice that comments are optional and that the information about an item is separated from the information for the following item by an empty line.

Define the class CD. In addition to constructors, it should have access methods for each attribute plus modifiers for each attribute except uniqueId. It should have also methods for writing an item to a PrintWriter and for reading it from a Scanner.

Your main program will get the name of the file with item information as a command parameter. It will read the content of the file in an arraylist cdList. It should in a loop offer the following choices to the user:

  1. Create a new item entry.
    /* The user is prompted for the appropriate information and a CD with that information is added to cdList if not already there */
  2. Delete an existing item entry
    /* The user is prompted for the uniqueId of a CD and, if found in cdList, it is removed from there */
  3. Update modifiable attributes of an item
    /* The user is prompted for the uniqueId of an item, the item is displayed and for each attribute the user is asked if to modify the value, and if yes, it is prompted for the new value */
  4. List items
    /* List the items in cdList */
  5. Import item data from a file.
    /* The user is prompted for the name of the file. Then the content of this file is merged without duplication (two items are duplicates if with the same uniqueId) with the current list).*/
  6. Export item data to a file.
    /* The user is prompted for the name of a file. Then everything is as in List items case with the difference that now the items are sent to the file instead of being diplayed.
  7. Terminate.
When the program terminates the current content is saved to the file whose name is obtained from the original input file: if the input file was cdss07.txt, the output file will be cdss07-new.txt.

Send to the TA a case analysis for this problem: problem statement, analysis, design, implementation, and testing.