Question: #include playlist.h Playlist::Playlist ( ) { firstSong = lastSong = nullptr; / / if using default, nothing in queue numberSongsLoaded = 0 ; name
#include "playlist.h
Playlist::Playlist
firstSong lastSong nullptr; if using default, nothing in queue
numberSongsLoaded ;
name "Playlist";
Playlist::PlaylistSong f Song l int n string nm
left in to showcase moving through a queue
this WILL NOT compile until the underlined methods are implemented
numberSongsLoaded n;
name nm;
iff nullptr
firstSong lastSong nullptr;
return;
Song temp f;
firstSong lastSong new Song;
firstSongsetArtisttempgetArtist;
firstSongsetTitletempgetTitle;
firstSongsetNextSongnullptr;
temp tempgetNextSong;
whiletemp nullptr
lastSongsetNextSongnew Song;
lastSong lastSonggetNextSong;
lastSongsetArtisttempgetArtist;
lastSongsetTitletempgetTitle;
lastSongsetNextSongnullptr;
temp tempgetNextSong;
write a copy constructor
this will look very similar to the parameretized constructor
Playlist::Playlistconst Playlist& rhs
firstSong rhsfirstSong;
lastSong rhslastSong;
numberSongsLoaded rhsnumberSongsLoaded;
name rhsname;
Song temp rhsfirstSong;
whiletemp nullptr
this temp;
temp tempgetNextSong;
write a desctructor
this will iterate through playlist and delete all items
Playlist::~Playlist
while firstSong nullptr
deleteSongFromEnd;
getters
string Playlist::getName
return name;
setters
void Playlist::setNamestring nm
name nm;
write a method to check if song is already in playlist
will iterate through queue and check a passed song against songs already in playlist
bool Playlist::isSongInPlaylistconst Song& songconst
Song temp firstSong;
whiletemp nullptr
iftempgetTitle song.getTitle&&tempgetArtist song.getArtist
return true;
temp temp getNextSong;
return false;
will
create the public adder method
this should add a song at the beginning of the playlist
void Playlist::addSongAtBeginningconst Song& song
Song newSong new Songsong;
newSongsetNextSongfirstSong;
firstSong newSong;
if lastSong nullptr
lastSong firstSong;
numberSongsLoaded;
create the private delete method
this should delete the song at the end of the playlist
check if there are no songs left in the playlist
void Playlist::deleteSongFromEnd
iffirstSong nullptr;
return;
iffirstSong lastSong
delete firstSong;
firstSong lastSong nullptr
else
Song temp firstSong;
whiletemp getNextSong lastSong
temp tempgetNextSong;
delete lastSong;
lastSong temp;
lastSongsetNextSongnullptr;
numberSongsLoaded;
create the public delete method
delete song at specific index position
void Playlist::deleteSongAtint i
ifi i numberSongsLoaded;
return;
ifi
Song temp firstSong;
firstSong firstSonggetNextSong;
delete temp;
iffirstSong nullptr
lastSong nullptr;
else
Song prev firstSong;
forint i ; igetNextSong;
Song temp prevgetNextSong;
prev setNextSongtemp getNextSong;
iftemp lastSong;
lastSong prev;
delete temp;
numberSongsLoaded;
create a method that gets a song at a specific index position
this will be used in the delete and adder methods
Song Playlist::getSongAtint iconst
ifi i numberSongsLoaded;
return nullptr;
Song temp firstSong;
forint i ; i index; i
temp tempgetNextSong;
return temp;
void Playlist::displayLoadedSongsbool displayNumbersconst
iffirstSong nullptr
cout No songs are currently loaded for play." getTitle endl;
temp tempgetNextSong;
numDisp;
Playlist& Playlist::operatorconst Playlist& rhs
include a return this
firstSong rhsrhsfirstSong;
lastSong rhslastSong;
numberSongsLoaded rhsnumberSongsLoaded;
name rhsname;
Song
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
