Question
Description ( using c++) : For this program you will be creating a CD Collection as a member of a team. The CD list you
Description ( using c++) : For this program you will be creating a CD Collection as a member of a team. The CD list you are creating will be stored in memory using several structs with the ability to search by a particular artist and find their CDs and to sort the list based on the album title. Unlike previous programs, you do not know the size of the file that will be read into the program so your program should be able to resize your collection of CDs as necessary. As we discussed in class, the best way to accomplish this is to start with a relatively small array size (2-4), and then double the array size as your array becomes full. This program will be challenging and will bring together most of the concepts we have covered this semester.
** Please show Song.h, Song.cpp, CD.h, CD.cpp. CDs.h, CDs.cpp, and CDDriver.cpp files **
For this program, you will create multiple files to allow the program to create individual CDs by parsing the text file supplied as a command line argument. The file containing the sample data is titled CD.txt and its format is described in detail below. For the purposes of this assignment, you can assume that the sample file and the file I will use follow the same formatting. The files you will create will include:
Song.h
Song.h will include an include guard, a struct named, appropriately enough, Song and the functional prototypes required to create, display and destroy an individual Song. A Song is made up of the following information:
A string for the title of the song
A string for the length of the song
The functions that are necessary for this program are namely:
Song* createSong (string title, string length);
void displaySong (Song* s);
void destroySong (Song* s);
Song.cpp
Song.cpp will contain all of the code necessary to implement the functions that are prototyped in Song.h
CD.h
CD.h will include an include guard, a struct named, appropriately enough, CD and the functional prototypes required to create, display and destroy an individual CD. A CD is made up of the following information:
A string for the artist
A string for the title of the CD
An integer containing the year the CD was released
An integer indicating the rating the CD has earned
An integer indicating the number of individual Song on the CD
An array of pointers of type Song (Song** songs) holding the songs present on that CD
The functions that are necessary for this program are namely:
CD* createCD (string artist, string title, int year, int rate, int numSongs);
void displayCD (CD* c);
void destroySong (CD* c);
void addSong (CD* cd, string title, string length);
addSong will create a new Song and add that song to the songArray inside CD
CD.cpp
CD.cpp will contain all of the code necessary to implement the functions that are prototyped in CD.h
CDs.h
CDs.h will include an include guard, a struct named, appropriately enough, CDs and the functional prototypes required to create, display and destroy CDs. CDs are made up of the following information:
An array of individual CD (CD** cdArray)
The maximum size of the CD array
The current size of the CD array
The functions that are necessary for this program are namely:
CDs* createCDs (const char* filename);
void displayCDs (CDs* c);
void destroyCDs (CDs* c);
CDs* findCDs (CDs* cds, string artist);
CDs* sortCDs (CDs* cds);
findCDs will search the CDs struct for albums for the artist the user has asked for. It will return a pointer to a new CDs struct containing all of the individual CD structs by that artist
Note : Since your findCDs and your sortCDs functions return a new CDs*, several different CD collections can exist meaning multiple CDs structs are pointing at the same information. This means you will need to be careful with your destroy methods to make sure you do not destroy a valid CD title.
CDs.cpp
CDs.cpp will contain all of the code necessary to implement the functions that are prototyped in CDs.h
CDDriver.cpp
Your CDDriver should control all interaction with the user and call the functions in CDs.cpp to return the desired results. It should not call any functions in CD.cpp or Song.cpp directly.
Input
The users will use command line arguments to specify a file containing the CD's you will be importing. The input file I will provide cds.txt follows the same formatting all of my test files will adhere to. The files is formatted so that all information for an individual CD is grouped together, but at no time are you told the total number of CD's in the file.
Output
Your program should read in the CDs, store them in your CD array. It should then present a menu to the user and allow them to choose to find CDs by a particular artist or to sort the ENTIRE original CD collection. If the artist exists, all CDs by that artist should be displayed to the screen. If the artist does not exist an appropriate message should be displayed. If the user selects to sort the collection, the entire original collection should be sorted and displayed to the screen. The user should then be asked to search for an artist until they terminate the program.
Sample Output
Welcome to the CD's Enter your selection below : 1. Find the CDs by an artist 2. Sort the CD listing 3. Exit Enter your choice: 1 Enter an artist to obtain their CDs in the collection: Insomnium Artist: Insomnium Title: Across the Dark Year: 2009 Rating: 10 1 Equivalence 3:18 2 Down With The Sun 4:23 3 Where The Last Wave Broke 5:03 4 The Harrowing Years 6:39 5 Against The Stream 6:11 6 The Lay Of Autumn 9:08 7 Into The Woods 5:08 8 Weighted Down With Sorrow 5:51 9 The New Beginning 7:15 Artist: Insomnium Title: In The Halls of Awaiting Year: 2002 Rating: 9 1 Ill-Starred Son 4:49 2 Song of the Storm 4:24 3 Medeia 4:24 4 Dying Chant 4:15 5 The Elder 4:49 6 Black Waters 5:02 7 Shades of Deep Green 7:35 8 The Bitter End 5:10 9 Journey Unknown 4:34 10 In the Halls of Awaiting 10:55 ... Enter your selection below : 1. Find the CDs by an artist 2. Sort the CD listing 3. Exit Enter your choice: 1 Enter an artist to obtain their CDs in the collection: Iggy Pop I am sorry, no CDs by that artist were found. Enter your selection below : 1. Find the CDs by an artist 2. Sort the CD listing 3. Exit Enter your choice: 3 Have a nice day
Input Validation
Your program should make sure the user has supplied the required number of command line arguments. If the correct number has not been entered it should supply the appropriate format of expected input and ask for the information. In addition, your program should also test for the existence of the supplied CD file and warn if it does not exist before ending gracefully.
The cds.txt file is too long to put in the question, so please set up a sample txt file and show what you have in it so I can test it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started