Project 1 - A CD Database

Due - Thursday, March 9, 2006

The goal of this project is to give you experience using classes, pointers, and inheritance. You will write a program that keeps track of your CD collection. It will read from a file information about your collection and store the information in an array of pointers. You will need to dynamically allocate memory for each CD object. Next, your program will display the information to the screen and enable the user to select from the following operations:
  1. Add a New CD: If the user chooses to add a new CD to her collection, you should ask her for the name of the artist and name of the album she would like to add. Store this information in the database and perform any other necessary updates.
  2. Delete a CD: If the user chooses to delete a CD from her collection, you should ask her which CD she would like to delete. To make your delete function easier to implement, modify your print procedure to print out a number associated with each CD. For example, print (1 of 3) above the first CD in a collection of 3. The user should enter the number corresponding to the CD she would like to delete and your program should delete that entry from the array (and free the associated memory!).
  3. Search: If the user chooses to search for a particular artist, your program should ask the user which artist she would like to search for. Then, perform a linear search of the array and print out any CDs by that artist.
  4. Quit: If the user chooses to quit, you should ask the user for the name of the file where she would like to save the updated collection. Then, save all of the information stored in the array into a file with that name.
The format of your file should look as follows:
4
Madonna
Like a Prayer
Pop
Talking Heads
Naked
Pop
Brooks, Garth
the hits
Country
Various Artists
Chicago
Soundtrack

The first character of the file is an integer that represents the number of records stored in the file. Each entry contains the name of the artist, the name of the album, and the genre of music. If you wish to add additional information, for example number of tracks, please modify the format of the file accordingly and submit a sample file when you submit your program.

Implementation Requirements and Hints

  1. For 90 percent credit, you must have a class to represent a single CD, a class to represent your database of CDs, and a class that manages the user interface. For the remaining 10 percent credit, you must also define one or more derived classes that inherit from your CD class. At minimum, you must define a derived class to represent a soundtrack CD. A soundtrack is unique in that it does not have a single artist. You should take this into consideration when you print the information about the CD.

Extra Credit Opportunity

For extra credit, maintain your list of CDs sorted by artist name. This will affect your insertion, deletion, and find operations.

Due 2:40PM Thursday March 9, 2006

  1. Complete and submit your working code.
  2. Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
  3. Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other source including another text book, a web page, or another student (current or former). You must provide citations for any sources you have used in designing and implementing your program.
Sami Rollins