Question: C++ The following class has been provided (do not implement this class) Use this class to represent time values in Player class. It's listed below...
C++ The following class has been provided (do not implement this class) Use this class to represent time values in Player class. It's listed below...
// Tests the Player class, which manages songs on a music player device. #include using namespace std; #include "Player.h" using namespace std; int main() { Player ipod("iPod touch", 32.0); ipod.addSong("Pink Floyd", "Hey You", "4:41", 10.82); // expecting "Song is alredy present." ipod.addSong("Pink Floyd", "Hey You", "4:41", 10.82); ipod.addSong("The Doors", "Light My Fire", "7:06", 15.90); // expecting "Not enough memory." ipod.addSong("The Rolling Stones", "Gimme Shelter", "4:30", 10.33); ipod.addSong("The Rolling Stones", "Gimme Shelter", "4:30", 5.27); ipod.displaySongInfo("Pink Floyd", "Hey You"); // expecting 3 songs, total length of 16:17 and 0.01 Mb of free space left ipod.deviceInfo(); ipod.removeSong("Pink Floyd", "Hey You"); // expecting 2 songs, total length of 11:36 and 10.83 Mb of free space left ipod.deviceInfo(); Player sony("Sony Walkman", 64.0); // expecting "Song was not found!" sony.removeSong("The Doors", "Light My Fire"); sony.addSong("Nirvana", "Polly", "2:57", 6.76); sony.addSong("Metallica", "Turn The Page", "6:06", 14.06); sony.addSong("Cream", "White Room", "5:03", 11.64); // expecting order: Nirvana, Cream, Metallica sony.displaySongsByLength(); // expecting 3 songs, total length of 14:06 and 31.54 Mb of free space left sony.deviceInfo(); } Player:
You should implement the operations listed below for the Player class. Use the function descriptions to determine what the member variables should be. However, you must declare a Song struct to store the data for a single song (make it a private member), and you must have an array of Song structures as a member variable.
Player(string name, float size) a constructor for the class. name' is a name for it 'size' is a maximum capacity in Mb.
addSong(string band, string title, string length, float size) a function for adding a new song.
'band' is a name of the band 'title' is a name of the song 'length' is a time length of that song in a '1:23' format (mm:ss") 'size' is a size of the song in Mb
Return true if the song was added and false if there was not enough space (memory) for it or there was a song with the same band and title already in that device or if the device already has 1000 songs in it.
removeSong(string band, string title) a function for removing a song 'band' is a name of the band 'title' is a name of the song
Return true if the song was successfully removed and false if it wasn't present on the device.
displaySongInfo(string band, string title) a function to display a songs info in the following format: Band:
Length:
Number of songs: Total length:
Free space left: The output must line up in two columns, but the labels may be right justified.
******NOTES*****
Do removeSong last!!
Create a makefile to compile and test the Player class. There will be four goals in this makefile, because you will have three .cpp files. Use the makefile from the timedemo example and modify it to work with these new files. Use the following names for your files:
TimeStamp.h TimeStamp.cpp Player.h Player.cpp Driver.cpp -----> listed below...
#makefile for Time class with three files: # Time.h, Time.cpp, Driver.cpp a.out: Driver.o Time.o g++ Driver.o Time.o Driver.o: Driver.cpp Time.h g++ -c Driver.cpp Time.o: Time.cpp Time.h g++ -c Time.cpp
Put complete header comments at the top of Player.h and Player.cpp.
DO NOT change the names of the classes, functions or files.
You do NOT need to use binary search for this assignment.
Implement the common part of addSong, removeSong, and displaySongsearching for a given songin a separate function. Do not duplicate the code for search!
You may add additional private functions as needed.
This is an example of what the output should look like...
/* Song is already present. Not enough memory. Song info: Band: Pink Floyd Title: Hey You Length: 4:41 Size: 10.82 Mb Device info: Name: iPod touch Songs: 3/1000 Total length: 16:17 Free space left: 0.01 Mb Device info: Name: iPod touch Songs: 2/1000 Total length: 11:36 Free space left: 10.83 Mb Song was not found! All songs sorted by length: Band: Nirvana Title: Polly Length: 2:57 Size: 6.76 Mb Band: Cream Title: White Room Length: 5:03 Size: 11.64 Mb Band: Metallica Title: Turn The Page Length: 6:06 Size: 14.06 Mb Device info: Name: Sony Walkman Songs: 3/1000 Total length: 14:06 Free space left: 31.54 Mb */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
