SlideShare a Scribd company logo
1 of 11
Download to read offline
Exercise 3:
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.
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 will set the currentSong
pointer to that location in the playlist before printing both the title and singer (e.g., Now playing
by ) . Use the eraseInDLL function definition to implement delete.
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.
*You may use provided main function in Ex3.cpp file to continue.
Sample Output:
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 1
Enter song title: Trouble
Enter singer: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 6
Printing playlist...
Title: Staying Alive
Artist: Bee Gees
Title: Hotel California
Artist: The Eagles
Title: Saturnalia
Artist: Marilyn Manson
Title: Potions
Artist: Puscifer
Title: Trouble
Artist: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 3
Enter the title of the song to play: Trouble
Enter singer: Taylor Swift
Now playing...
Title: Trouble
Artist: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 4
Now Playing...
Title: Staying Alive
Artist: Bee Gees
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 5
Now Playing...
Title: Trouble
Artist: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 1
Enter song title: Lavender Haze
Enter singer: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 4
Now Playing...
Title: Lavender Haze
Artist: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 6
Printing playlist...
Title: Staying Alive
Artist: Bee Gees
Title: Hotel California
Artist: The Eagles
Title: Saturnalia
Artist: Marilyn Manson
Title: Potions
Artist: Puscifer
Title: Trouble
Artist: Taylor Swift
Title: Lavender Haze
Artist: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 2
Enter the title of the song to delete: Lavender Haze
Enter singer: Taylor Swift
Deleted!
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 6
Printing playlist...
Title: Staying Alive
Artist: Bee Gees
Title: Hotel California
Artist: The Eagles
Title: Saturnalia
Artist: Marilyn Manson
Title: Potions
Artist: Puscifer
Title: Trouble
Artist: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 5
Now Playing...
Title: Trouble
Artist: Taylor Swift
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 4
Now Playing...
Title: Staying Alive
Artist: Bee Gees
1. Add a Song
2. Delete a Song
3. Play a Song
4. Forward
5. Backward
6. Show Playlist
7.Exit
Choose an option: 7
Exiting playlist...
#include
#include
using namespace std;
class Song {
public:
Song(string t = "", string s = "") : title{ t }, singer{ s }{ }
friend ostream &operator<<(ostream &out, const Song & s) {
out << "Title: " << s.getTitle() << "nArtist: " << s.getSinger() << endl<
struct DoubleNode
{
Object data;
DoubleNode *prev;
DoubleNode *next;
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
void createDoublyLinkedList(Object ary[], int size,DoubleNode*& head,DoubleNode*& tail)
{
head = new DoubleNode(ary[0]);
DoubleNode* temp = head;
for (int i = 1; i < size; i++)
{
DoubleNode* node = new DoubleNode(ary[i]);
temp->next = node;
node->prev = temp;
temp = node;
}
tail = temp;
}
template
void printDLL(DoubleNode* head)
{
while (head != nullptr)
{
cout << head->data;
head = head->next;
}
cout << endl;
}
template
bool eraseInDLL(DoubleNode*& head, DoubleNode*& tail, Object givenValue) {
DoubleNode *temp = head;
// your code
}
void menu() {
cout <<"1. Add a Songn"
<<"2. Delete a Songn"
<<"3. Play a Songn"
<<"4. Forwardn"
<<"5. Backwardn"
<<"6. Show Playlistn"
<<"7.Exitn"
<<"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* head;
DoubleNode * tail;
createDoublyLinkedList(MusicList, 4,head,tail);
DoubleNode *currentSong =head;
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 *newSong = new DoubleNode(Song(title,singer));
//your code goes here
}
break;
case 2: // Delete a Song
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: //print all
//your code goes here
break;
case 7: //Exit
cout << "Exiting playlist...nn";
break;
}
} while (option != 7);
return 0;
}

More Related Content

More from facevenky

double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdffacevenky
 
Do the following well, read all directions, I asked this question be.pdf
Do the following well, read all directions, I asked this question be.pdfDo the following well, read all directions, I asked this question be.pdf
Do the following well, read all directions, I asked this question be.pdffacevenky
 
Double linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdfDouble linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdffacevenky
 
Digital Communication SystemsObjectives 1 To be able to demons.pdf
Digital Communication SystemsObjectives 1 To be able to demons.pdfDigital Communication SystemsObjectives 1 To be able to demons.pdf
Digital Communication SystemsObjectives 1 To be able to demons.pdffacevenky
 
Diagonal communicationa) is the traditional flow of communication .pdf
Diagonal communicationa) is the traditional flow of communication .pdfDiagonal communicationa) is the traditional flow of communication .pdf
Diagonal communicationa) is the traditional flow of communication .pdffacevenky
 
Depicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdf
Depicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdfDepicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdf
Depicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdffacevenky
 
Create a diagram for the following scenario The music streaming serv.pdf
Create a diagram for the following scenario The music streaming serv.pdfCreate a diagram for the following scenario The music streaming serv.pdf
Create a diagram for the following scenario The music streaming serv.pdffacevenky
 
Create a function that will read the saved projects from localStorag.pdf
Create a function that will read the saved projects from localStorag.pdfCreate a function that will read the saved projects from localStorag.pdf
Create a function that will read the saved projects from localStorag.pdffacevenky
 
Dawn Company general ledger shows the following account balances amo.pdf
Dawn Company general ledger shows the following account balances amo.pdfDawn Company general ledger shows the following account balances amo.pdf
Dawn Company general ledger shows the following account balances amo.pdffacevenky
 
Create a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdfCreate a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdffacevenky
 
Dave and his friend Stewart each owns 50 percent of KBS. During the .pdf
Dave and his friend Stewart each owns 50 percent of KBS. During the .pdfDave and his friend Stewart each owns 50 percent of KBS. During the .pdf
Dave and his friend Stewart each owns 50 percent of KBS. During the .pdffacevenky
 
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdfCopy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdffacevenky
 
Contreras article is about different reforms that have been introdu.pdf
Contreras article is about different reforms that have been introdu.pdfContreras article is about different reforms that have been introdu.pdf
Contreras article is about different reforms that have been introdu.pdffacevenky
 

More from facevenky (13)

double linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdfdouble linked list header file code#include iostream#include.pdf
double linked list header file code#include iostream#include.pdf
 
Do the following well, read all directions, I asked this question be.pdf
Do the following well, read all directions, I asked this question be.pdfDo the following well, read all directions, I asked this question be.pdf
Do the following well, read all directions, I asked this question be.pdf
 
Double linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdfDouble linked list header file below for FYI#include iostream.pdf
Double linked list header file below for FYI#include iostream.pdf
 
Digital Communication SystemsObjectives 1 To be able to demons.pdf
Digital Communication SystemsObjectives 1 To be able to demons.pdfDigital Communication SystemsObjectives 1 To be able to demons.pdf
Digital Communication SystemsObjectives 1 To be able to demons.pdf
 
Diagonal communicationa) is the traditional flow of communication .pdf
Diagonal communicationa) is the traditional flow of communication .pdfDiagonal communicationa) is the traditional flow of communication .pdf
Diagonal communicationa) is the traditional flow of communication .pdf
 
Depicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdf
Depicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdfDepicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdf
Depicted below is footnote #5 for Boeing, Co. for FYE 2021 and 2020,.pdf
 
Create a diagram for the following scenario The music streaming serv.pdf
Create a diagram for the following scenario The music streaming serv.pdfCreate a diagram for the following scenario The music streaming serv.pdf
Create a diagram for the following scenario The music streaming serv.pdf
 
Create a function that will read the saved projects from localStorag.pdf
Create a function that will read the saved projects from localStorag.pdfCreate a function that will read the saved projects from localStorag.pdf
Create a function that will read the saved projects from localStorag.pdf
 
Dawn Company general ledger shows the following account balances amo.pdf
Dawn Company general ledger shows the following account balances amo.pdfDawn Company general ledger shows the following account balances amo.pdf
Dawn Company general ledger shows the following account balances amo.pdf
 
Create a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdfCreate a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdf
 
Dave and his friend Stewart each owns 50 percent of KBS. During the .pdf
Dave and his friend Stewart each owns 50 percent of KBS. During the .pdfDave and his friend Stewart each owns 50 percent of KBS. During the .pdf
Dave and his friend Stewart each owns 50 percent of KBS. During the .pdf
 
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdfCopy your completed LinkedList class from Lab 3 into the LinkedList..pdf
Copy your completed LinkedList class from Lab 3 into the LinkedList..pdf
 
Contreras article is about different reforms that have been introdu.pdf
Contreras article is about different reforms that have been introdu.pdfContreras article is about different reforms that have been introdu.pdf
Contreras article is about different reforms that have been introdu.pdf
 

Recently uploaded

Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 

Recently uploaded (20)

Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 

Exercise 3 You are to code some simple music player application .pdf

  • 1. Exercise 3: 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. 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 will set the currentSong pointer to that location in the playlist before printing both the title and singer (e.g., Now playing by ) . Use the eraseInDLL function definition to implement delete. 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. *You may use provided main function in Ex3.cpp file to continue. Sample Output: 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 1 Enter song title: Trouble Enter singer: Taylor Swift 1. Add a Song 2. Delete a Song
  • 2. 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 6 Printing playlist... Title: Staying Alive Artist: Bee Gees Title: Hotel California Artist: The Eagles Title: Saturnalia Artist: Marilyn Manson Title: Potions Artist: Puscifer Title: Trouble Artist: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 3 Enter the title of the song to play: Trouble Enter singer: Taylor Swift Now playing...
  • 3. Title: Trouble Artist: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 4 Now Playing... Title: Staying Alive Artist: Bee Gees 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 5 Now Playing... Title: Trouble Artist: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward
  • 4. 5. Backward 6. Show Playlist 7.Exit Choose an option: 1 Enter song title: Lavender Haze Enter singer: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 4 Now Playing... Title: Lavender Haze Artist: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 6 Printing playlist... Title: Staying Alive Artist: Bee Gees Title: Hotel California
  • 5. Artist: The Eagles Title: Saturnalia Artist: Marilyn Manson Title: Potions Artist: Puscifer Title: Trouble Artist: Taylor Swift Title: Lavender Haze Artist: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 2 Enter the title of the song to delete: Lavender Haze Enter singer: Taylor Swift Deleted! 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 6
  • 6. Printing playlist... Title: Staying Alive Artist: Bee Gees Title: Hotel California Artist: The Eagles Title: Saturnalia Artist: Marilyn Manson Title: Potions Artist: Puscifer Title: Trouble Artist: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 5 Now Playing... Title: Trouble Artist: Taylor Swift 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward
  • 7. 6. Show Playlist 7.Exit Choose an option: 4 Now Playing... Title: Staying Alive Artist: Bee Gees 1. Add a Song 2. Delete a Song 3. Play a Song 4. Forward 5. Backward 6. Show Playlist 7.Exit Choose an option: 7 Exiting playlist... #include #include using namespace std; class Song { public: Song(string t = "", string s = "") : title{ t }, singer{ s }{ } friend ostream &operator<<(ostream &out, const Song & s) { out << "Title: " << s.getTitle() << "nArtist: " << s.getSinger() << endl< struct DoubleNode { Object data; DoubleNode *prev; DoubleNode *next; DoubleNode(const Object & d = Object{}, DoubleNode * p = nullptr, DoubleNode * n = nullptr) : data{ d }, prev{ p }, next{ n } { }
  • 8. }; //function to create Doubly Linked List with values template void createDoublyLinkedList(Object ary[], int size,DoubleNode*& head,DoubleNode*& tail) { head = new DoubleNode(ary[0]); DoubleNode* temp = head; for (int i = 1; i < size; i++) { DoubleNode* node = new DoubleNode(ary[i]); temp->next = node; node->prev = temp; temp = node; } tail = temp; } template void printDLL(DoubleNode* head) { while (head != nullptr) { cout << head->data; head = head->next; } cout << endl; } template bool eraseInDLL(DoubleNode*& head, DoubleNode*& tail, Object givenValue) { DoubleNode *temp = head; // your code } void menu() { cout <<"1. Add a Songn"
  • 9. <<"2. Delete a Songn" <<"3. Play a Songn" <<"4. Forwardn" <<"5. Backwardn" <<"6. Show Playlistn" <<"7.Exitn" <<"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* head; DoubleNode * tail; createDoublyLinkedList(MusicList, 4,head,tail); DoubleNode *currentSong =head; Song song; bool found = false; int option; do { menu(); cin >> option; cout << endl;
  • 10. 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 *newSong = new DoubleNode(Song(title,singer)); //your code goes here } break; case 2: // Delete a Song 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
  • 11. //your code goes here break; case 5: //backward //your code goes here break; case 6: //print all //your code goes here break; case 7: //Exit cout << "Exiting playlist...nn"; break; } } while (option != 7); return 0; }