Question
Please answer using the below driver code template You are to code some simple music player application making appropriate use of doubly linked lists with
Please answer using the below driver code template
You are to code some simple music player application making appropriate use of doubly linked lists with head and tail, as described hereafter.
Create a doubly linked list for a music playlist. a. Provide a Song class that has a title and a singer as data members. b. Create a doubly linked list, with a head node (musicPlaylist) pointing to the first song on the list. c. Display a menu for the user to choose an option, as follows: 1. Add a song 2. Delete a song 3. Play a song 4. Skip forward 5. Skip backward 6. Exit Adding and deleting songs (#1-2) should update the playlist accordingly. Adding a song places it at the end of the list. Playing a song (#3) will prompt the user to enter the title of the song and print both the title and singer (e.g., Now playing by ) Skipping forward or backward (#4-5) will jump to the previous song or the next song, respectively, and display its title and singer (as per above). Skip forward on the last song takes you to the beginning of the list. Skip backward on the first song takes you to the last song of the list. Exit will quit the program. GIVEN THE C++ TEMPLATE
#include
friend ostream &operator<<(ostream &out, const Song & s) { out << "Title: " << s.getTitle() << " Artist: " << s.getSinger() << endl< bool operator==(const Song &rhs) { if ((rhs.title == title) && (rhs.singer == singer)) return true; else return false; } string getTitle() const { return title; } string getSinger() const { return singer; } void setTitle(string t) { title = t; } void setSinger(string s) { singer = s; } Song &operator=(const Song &s) { title = s.title; singer = s.singer; return *this; } private: string title; string singer; }; //Doubly Linked List structure template DoubleNode(const Object & d = Object{}, DoubleNode * p = nullptr, DoubleNode * n = nullptr) : data{ d }, prev{ p }, next{ n } { } }; //function to create Doubly Linked List with values template tail = temp; } template void menu() { cout <<"1. Add a Song " <<"2. Delete a Song " <<"3. Play a Song " <<"4. Forward " <<"5. Backward " <<"6. Show Playlist " <<"7.Exit " <<"Choose an option: "; } int main() { string title; string singer; bool success; Song MusicList[10]; Song a("Staying Alive", "Bee Gees"); MusicList[0] = a; Song b("Hotel California", "The Eagles"); MusicList[1] = b; Song c("Saturnalia", "Marilyn Manson"); MusicList[2] = c; Song d("Potions", "Puscifer"); MusicList[3] = d; DoubleNode DoubleNode Song song; bool found = false; int option; do { menu(); cin >> option; cout << endl; cin.ignore(); cin.clear(); switch (option) { case 1: // Add a Song { cout << "Enter song title: "; getline(cin, title); cout << "Enter singer: "; getline(cin, singer); DoubleNode cout << "Enter the title of the song to delete: "; getline(cin, title); cout << "Enter singer: "; getline(cin, singer); //your code goes here break; case 3: // Paly a Song found = false; cout << "Enter the title of the song to play: "; getline(cin, title); cout << "Enter singer: "; getline(cin, singer); song.setTitle(title); song.setSinger(singer); //your code goes here break; case 4: //forward //your code goes here break; case 5: //backward //your code goes here break; case 6: //Display Playlist printDLL(head); break; case 7: //exit cout << "Exiting playlist... "; break; } } while (option != 7); return 0; }
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