Project 3, A Simple Music Database.
Short Description:
Write the supporting classes for a simple music database.
Goals
When you finish this project, you should have:
- Created multiple classes from a given specification.
Formal Description
For this project, you will be implementing four classes used in a simple music database. The header files for these classes are here:
You must implement the classes without changing these header files.
In addition you will need ProjectConstants.h. You should not alter this file.
The main program for this database is project3.cpp. Your classes must compile and work with this program.
In the following description, information in the header file takes precedence over the written description. (I did not intentionally insert errors, but there may be. The header files are correct).
Implement the following classes
- ArtistT
- This class defines an artist.
- Implement this in
ArtistT.cpp
- Your class must implement this header file ArtistT.h
- ArtistListT
- This class holds a list of artists.
- Use the header file ArtistListT.h
- Implement this in
ArtistListT.cpp
- The artists should be stored in positions 0 through n-1 where n is the number of artists.
- Data
- An array of ArtistT, at most MAX_ARTISTS as defined in ProjectConstants.h
- The current number of artists.
- Methods
- A constructor.
- InsertArtist
- Input: ArtistT
- Output: returns a true if the artist was successfully inserted.
- This can fail and return false
- if the artist already exists
- if the array is out of space.
- FindArtistByID, this is a private member function.
- Input: an artist ID
- Output: an index
- If the artist is in the array, the position of that artist.
- If the artist is not in the array, the number of artists in the array (size, not capacity)
- FindArtistByName, this is a private member function.
- Input: An artist name.
- Output: an index
- The position of the artist if they are in the array
- The size of the array if not (size, not capacity)
- ValidID
- Input: An artist id
- Output:
- True if an artist with the given id is in the array.
- False otherwise
- Note, -1 is not a valid id.
- ValidArtistName
- Input: a string
- Output: bool indicating if the named artist is in the array.
- GetArtistByID
- Input the artist id
- Output
- An ArtistT containing the artist if the artist is in the array.
- The default ArtistT if not.
- GetArtistByName
- Input the artist name
- Output
- An ArtistT containing the artist if the artist is in the array.
- The default ArtistT if not.
- GetArtistByIndex
- Input an index into the array
- Output
- An ArtistT containing the artist if the artist is in the array.
- The default ArtistT if not.
- UpdateArtist
- Input an ArtistT
- Replace the artist in the array with the same id as the input with the input.
- If artist is not in the array, do nothing.
- SortByName
- Sort the array alphabetically based on the name.
- Size
- Return the number of artists contained in the array.
- SongT
- Implement using the file SongT.h
- Implement this in the file
SongT.cpp
- This class represents a song.
- Member Data
- The title of the song.
- The artist id
- A song id
- Member Functions
- Constructor
- Title
- Input : none
- Returns the song title.
- Title
- Input: a string
- Sets the song title.
- ID
- Input: none
- Returns the song id
- ID
- Input: an integer
- Sets the song ID
- ArtistID
- Input: none
- Returns the associated artist id.
- ArtistID
- Input: The artist id
- Sets the artist id
- SongListT
- This data structure represents a list of songs.
- Implement based on the header file SongListT.h
- Implement this in
SongListT.cpp
- Member Data
- An array of SongT
- The number of songs stored in the array.
- Member Functions
- InsertSong
- Input: A SongT
- If a song with the same ID is not in the array, and there is space, the function succeeds and the song is inserted.
- Output: Returns true on success or false on failure
- ValidID
- Input: A song ID
- Output: True if the ID matches a song in the array, false otherwise.
- Note, -1 is not a valid id.
- ValidSongTitle
- Input: A song title
- Output: True if the title matches a song in the array, false otherwise.
- GetSongByID
- Input: A song id.
- Output: The song with a matching id if it is in the array, the default song otherwise.
- GetSongByTitle
- Input: The title of a song.
- Output: The song with a matching title if it is in the array, the default song otherwise.
- GetSongByIndex
- Input: An index into the array
- Output: The song with at the index position if the index is valid, the default song otherwise.
- UpdateSong
- Input: A SongT
- If a song with the corresponding
SongT id is in the array, replace it with the new version of the song.
- Output: None
- Sort
- Input: None
- Sort the array by song title.
- Output:one
- Size
- Input: None
- Output: The number of songs stored in the array.
- FindSongByTitle - this is a private function.
- Input: A song title
- Output: The position in the array of a song matching this title or the size of the array if it is not present.
- FindSongByID - this is a private function.
- Input: A song ID
- Output: The position in the array of a song matching this ID or the size of the array if it is not present.
You should also use the following files:
- Makefile.
- Songs.csv, a sample input file.
- testrun.txt a sample output file.
-
Each header file also has a print routine. Please implement these. They are not called in the final project, but are for debugging purposes.
- Your program compiles, without errors or warnings using the required compiler flags (as specified in the supplied Makefile) on the target platform (cslab103).
- Produces the correct output.
- Uses the required header files and main program without alteration.
- Uses good programming practices.
Do not retype any of the files, right click on the link and save-as.
Required Files
A single tar file containing the source code and Makefile for this program.
If you need to communicate last minute information with your instructor please place this in a file called ReadMe in this directory.
Submission
Upload your tar file to the Project3 d2l by the due date.