Question: Assignment # 2 : Doubly Linked Lists Implementing a Music Playlist Manager Overview In this assignment, you will use doubly - linked lists implemented in
Assignment # : Doubly Linked Lists
Implementing a Music Playlist Manager
Overview
In this assignment, you will use doublylinked lists implemented in C to develop a music
playlist manager. This manager will allow users to add songs, navigate through the playlist,
remove songs, and perform other typical playlist operations.
Requirements
You are required to implement several functions that a typical music player would have.
The playlist starts empty, and songs can be added, removed, or navigated through. Each
song will be represented as a string the song title within a node of the doublylinked list.
Class Definitions
You are given the class Playlist, which is a doublylinked list implementation that uses the
class DLLNode. Each song in the playlist will be represented using one DLLNode, where the
song title is a string within the node.
Sample Output
In the sample output below, the current active song is shown enclosed in parenthesis. For
example, in this list SongSong Song Song is the current active song. The
indicates previous songs, and indicates next songs.
Playlist myPlaylist;
cout myPlaylist endl;
cout myPlaylist.currval endl;
myPlaylist is empty
myPlaylist.addsongSong;
myPlaylist.addsongSong;
myPlaylist.addsongSong;
myPlaylist.addsongSong;
cout myPlaylist endl;
Song Song Song Song
cout myPlaylist.currval endl;
Song
myPlaylist.nextsong;
cout myPlaylist endl;
SongSong Song Song
cout myPlaylist.currval endl;
Song
myPlaylist.removesongSong;
cout myPlaylist endl;
SongSong Song
Task Descriptions
Adding a Song
o Implement the function addsong which takes a song title string and adds it
to the playlist. The new song should be added after the current song.
Navigating Forward
o Implement the function nextsong, which moves the current song to the next
song in the playlist. It should return the current active song title
Navigating Backward
o Implement the function previoussong, which moves the current song to the
previous song in the playlist. It should return the current active song title
Removing a Song
o Implement the function removesong, which removes a song from the
playlist based on the song title. If the current song is removed, the next song
should become the current song. If the removed song is the last one, the
previous song should become the current song.
Clearing the Playlist
o Implement the function clearplaylist, which clears all songs from the
playlist. The playlist should be empty after this operation.
Restrictions
All of your functions must run in time On in the worst case.
Class Declarations
Below are the skeleton declarations for DLLNode and Playlist classes. You need to
implement the member functions.
#include
#include
template
class DLLNode
public:
T data;
DLLNode prev;
DLLNode next;
DLLNodeconst T& data, DLLNode prev nullptr, DLLNode next nullptr
: datadata prevprev nextnext
;
template
class Playlist
private:
DLLNode head;
DLLNode tail;
DLLNode curr;
void clearforwardhistory;
public:
Playlist;
~Playlist;
void addsongconst T& song;
T nextsong;
T previoussong;
void removesongconst T& song;
void clearplaylist;
T currval const;
friend std::ostream& operatorstd::ostream& os const Playlist& pl;
;
Implementation Details
Constructor and Destructor:
o Implement the constructor to initialize the playlist.
o Implement the destructor to free the memory used by the nodes.
Adding a Song:
o Add a new song after the current song. If the playlist is empty, add the song
as the first song.
Navigating Forward and Backward:
o Move the current song pointer to the next or previous song, ensuring you do
not go out of bounds.
Removing a Song:
o Find the song by title and remove it from the list, adjusting the pointers
accordingly.
Clearing the Playlist:
o Remove all nodes from the playlist and reset it to the initial state.
Printing the Playlist:
o Overload the operator to print the playlist in the format described.
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
