CS 210 – Fundamentals of Programming I
Spring 2007 – Programming Project 2, Part B
70 points
Out: April 18/19
Due: April 30/May 1


Part B of this programming project is to implement the program you designed in Part A. The work must be entirely your own except for any help you may receive from the instructor. Name your main program file main.cpp, the files for the MusicLibrary class musiclib.h and musiclib.cpp, and the files for the Album class album.h and album.cpp (i.e., the ones from Programming Assignment 7).



Example Program Run

Assume that the file albumdata.dat contains the same album information that was shown in the example program run in Part A


Welcome to the CS 210 Music Library!

An empty music library has been created.

Please choose from the following actions:

    A. Initialize the music library
    B. Add a new album to the collection.
    C. Change the user rating of an album
    D. Print out information about an album
    E. Print out a list of all albums
    F. Print out a list of albums of the same genre
    G. Print out a list of albums recorded in the same year
    H. Print out a list of albums having at least a certain rating
    I. Print out a list of albums recorded by a particular artist
    J. Print out a random playlist of song tracks
    K. Print out the number of albums in the music library collection

    Q. Quit the program.

Your choice: A

Please enter the name of the input file: I:\albumdata.dat
The music library has been initialized.

Please choose from the following actions:

    A. Initialize the music library
    B. Add a new album to the collection.
    C. Change the user rating of an album
    D. Print out information about an album
    E. Print out a list of all albums
    F. Print out a list of albums of the same genre
    G. Print out a list of albums recorded in the same year
    H. Print out a list of albums having at least a certain rating
    I. Print out a list of albums recorded by a particular artist
    J. Print out a random playlist of song tracks
    K. Print out the number of albums in the music library collection

    Q. Quit the program.

Your choice: E

Artist             Title                            Year  Rating
----------------------------------------------------------------
Bruce_Springsteen  Born_to_Run                      1975    5
U2                 Joshua_Tree                      1987    5
The_Flaming_Lips   Yoshimi_Battles_the_Pink_Robots  2002    5
Yanni              Live_at_the_Acropolis            1993    4
Tim_McGraw         Live_Like_You_Were_Dying         2004    3

The rest of the actions would be the same as shown in Part A. If choice 'A' is made again with a different file, then the result of choice 'E' would show (only) the data from the second file.



Extra credit (up to 10 points)

Note: This extra credit problem is in addition to the above assignment. I.e., you must still submit a program that conforms with the original assignment.


Problem Statement

In iTunes it is possible for users to share music libraries allowing them to access and modify each others' music libraries. Extend your main program to handle multiple music libraries. When the program is started, it should have one MusicLibrary available that is designated as the current music library. It should include a new menu option to add a new (empty) MusicLibrary to the collection of music libraries. This action also should make the new music library the designated current music library. Another new option is to change the designated current music library. The "name" of a music library will be its index (between 0 and size-1) in the collection. All other menu options should be directed to the designated current music library. (See example program run below.)


Design Criteria

The collection of music libraries should be implemented using a vector of MusicLibrary objects in the main program. The current music library should be designated using an index variable that is used to access the current music library from the vector. You must not change the operations of either the MusicLibrary or Album classes.


Name your the main program file mainextra.cpp. Submit it and the four class files (musiclib.h, musiclib.cpp, album.h, and album.cpp) attached to a second, separate email message.


Example program run of extra credit

Welcome to the CS 210 Music Library!

Music library 0 is the current music library
Please choose from the following actions:

    A. Initialize the music library
    B. Add a new album to the collection.
    C. Change the user rating of an album
    D. Print out information about an album
    E. Print out a list of all albums
    F. Print out a list of albums of the same genre
    G. Print out a list of albums recorded in the same year
    H. Print out a list of albums having at least a certain rating
    I. Print out a list of albums recorded by a particular artist
    J. Print out a random playlist of song tracks
    K. Print out the number of albums in the music library collection
    L. Change the current music library
    M. Add a new music library

    Q. Quit the program.

Your choice: M

Music library 1 has been added

Music library 1 is the current music library
Please choose from the following actions:

    A. Initialize the music library
    B. Add a new album to the collection.
    C. Change the user rating of an album
    D. Print out information about an album
    E. Print out a list of all albums
    F. Print out a list of albums of the same genre
    G. Print out a list of albums recorded in the same year
    H. Print out a list of albums having at least a certain rating
    I. Print out a list of albums recorded by a particular artist
    J. Print out a random playlist of song tracks
    K. Print out the number of albums in the music library collection
    L. Change the current music library
    M. Add a new music library

    Q. Quit the program.

Your choice: A

Please enter the name of the input file: albumdata.dat
Music library 1 has been initialized

Music library 1 is the current music library
Please choose from the following actions:

    A. Initialize the music library
    B. Add a new album to the collection.
    C. Change the user rating of an album
    D. Print out information about an album
    E. Print out a list of all albums
    F. Print out a list of albums of the same genre
    G. Print out a list of albums recorded in the same year
    H. Print out a list of albums having at least a certain rating
    I. Print out a list of albums recorded by a particular artist
    J. Print out a random playlist of song tracks
    K. Print out the number of albums in the music library collection
    L. Change the current music library
    M. Add a new music library

    Q. Quit the program.

Your choice: K

There is/are 5 album(s) in the Music library 1 collection.

Music library 1 is the current music library
Please choose from the following actions:

    A. Initialize the music library
    B. Add a new album to the collection.
    C. Change the user rating of an album
    D. Print out information about an album
    E. Print out a list of all albums
    F. Print out a list of albums of the same genre
    G. Print out a list of albums recorded in the same year
    H. Print out a list of albums having at least a certain rating
    I. Print out a list of albums recorded by a particular artist
    J. Print out a random playlist of song tracks
    K. Print out the number of albums in the music library collection
    L. Change the current music library
    M. Add a new music library

    Q. Quit the program.

Your choice: L

Please enter the index of the music library you want: 0

Music library 0 is the current music library.
Please choose from the following actions:

    A. Initialize the music library
    B. Add a new album to the collection.
    C. Change the user rating of an album
    D. Print out information about an album
    E. Print out a list of all albums
    F. Print out a list of albums of the same genre
    G. Print out a list of albums recorded in the same year
    H. Print out a list of albums having at least a certain rating
    I. Print out a list of albums recorded by a particular artist
    J. Print out a random playlist of song tracks
    K. Print out the number of albums in the music library collection
    L. Change the current music library
    M. Add a new music library

    Q. Quit the program.

Your choice: K

There is/are 0 album(s) in the Music library 0 collection.

Note that Music library 0 is a defaulted constructed empty MusicLibrary object and all of the operations in the example went to Music library 1, so Music library 0 has no albums in it.

04/17/07 6