http://imgur.com/a/Pc3y2 This is the specs of my project that I would have to complete.
I have modified my "SongWrapper" class and named it "LibrarySong" for clarity.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
class LibrarySong : public Song{
public:
// Default constructor
LibrarySong(){
++iterativeID;
numOfPlays =0;
}
// Destructor
~LibrarySong() {};
//Get the ID of the song
static unsigned int getID(){
return iterativeID;
}
// Sets the number of plays of a song
void setNumOfPlays(int plays){
numOfPlays = plays;
}
// Gets the number of plays of a song
unsigned int getNumOfPlays(){
return numOfPlays;
}
private:
//static unsigned int counter;
static unsigned int iterativeID;
unsigned int numOfPlays;
};
unsigned int LibrarySong::iterativeID=0;
|
- I only have a default constructor at the moment because I was just thinking about using the ->get() to get the name and such.
- Instead of a counter, I just incremented the song ID by 1
- I propose that when a LibrarySong is created, it will create the Name, Artist, Album, #ofPlays, and the ID. I was thinking that
createSong should be in the Library class because once you create the song, it's automatically added into your Library.
I modified my playSong function in my Library class so that it will return the total number of times the song has been played. I will do something similar in my Playlist class to get the number of songs played, since the numbers of time the songs are played are different in the two classes.
1 2 3 4 5 6 7 8 9 10 11
|
unsigned int Library::playSong(unsigned int identifier, unsigned int numberOfPlays){
LibrarySong* aSong;
//Checks if there is a song with the ID
if(doesIdentifierExist(identifier) == false){
return 0;
}
aSong = aSongInLibrary.at(identifier);
aSong->setNumOfPlays(aSong->getNumOfPlays() + numberOfPlays);
return aSong->getNumOfPlays();
}
|
- My search function wouldn't require me to search for the name, artist, album, I would just need to search from the song ID number
- I changed the name of my first map so that I can better understand what it is actually mapping. That unordered_map maps a key to my SongLibrary*. So naming
aLibrary wouldn't make sense because that's not my actual "Library" that stores all the SongLibrary would be created.
- I will create an actual "Library" containing all the other songs in another class, therefore I don't think I will need to create anything else in the
LibrarySong class other than what I have already.
- When I was asked about Playlist class, I was given this answer.
“Library can expose an interface function that returns a (Library)Song* given a library song identifier. Keep in mind that Library and Playlists have dependencies in terms of songs, but they shouldn't really "know" about each other. Let the class that manages both the Library and all the Playlists take care of some of the system requirements (such as only adding a song to a Playlist if it exists in the library).”
- At the moment, the only functions I can think of inside my playlist class is
createPlaylistName,
changePlaylistName,
ratePlaylist,
doesPlaylistExist,
numberOfSongsInsidePlaylist. Maybe I can get LibrarySong* from the Library class and add it into my Playlist? Then I would also be able to do
removeSongFromPlaylist
- I created a function in my Library Class to get the LibrarySong* based on the ID of the song.
1 2 3 4
|
LibrarySong* Library::getSongFromLibrary(unsigned int identifier){
return aSongInLibrary.at(identifier);
}
|
To answer your question:
- I would store my LibrarySong* into a vector (perhaps) and that will become my "Library" in another class maybe called
Driver. The purpose of the
Driver class is being sort of like a "bridge" between the Library and the Playlist classes.
- My main() will just be the list of Commands that the user inputs and that's pretty much it.