SlideShare a Scribd company logo
1 of 7
Download to read offline
8.15 Program: Playlist (C++) You will be building a linked list. Make sure to keep track of both
the head and tail nodes. (1) Create three files to submit. Playlist.h - Class declaration Playlist.cpp
- Class definition main.cpp - main() function Build the PlaylistNode class per the following
specifications. Note: Some functions can initially be function stubs (empty functions), to be
completed in later steps. Default constructor (1 pt) Parameterized constructor (1 pt) Public
member functions InsertAfter() (1 pt) SetNext() - Mutator (1 pt) GetID() - Accessor
GetSongName() - Accessor GetArtistName() - Accessor GetSongLength() - Accessor GetNext()
- Accessor PrintPlaylistNode() Private data members string uniqueID - Initialized to "none" in
default constructor string songName - Initialized to "none" in default constructor string
artistName - Initialized to "none" in default constructor int songLength - Initialized to 0 in
default constructor PlaylistNode* nextNodePtr - Initialized to 0 in default constructor Ex. of
PrintPlaylistNode output: Unique ID: S123 Song Name: Peg Artist Name: Steely Dan Song
Length (in seconds): 237 (2) In main(), prompt the user for the title of the playlist. (1 pt) Ex:
Enter playlist's title: JAMZ (3) Implement the PrintMenu() function. PrintMenu() takes the
playlist title as a parameter and outputs a menu of options to manipulate the playlist. Each option
is represented by a single character. Build and output the menu within the function. If an invalid
character is entered, continue to prompt for a valid choice. Hint: Implement Quit before
implementing other options. Call PrintMenu() in the main() function. Continue to execute the
menu until the user enters q to Quit. (3 pts) Ex: JAMZ PLAYLIST MENU a - Add song d -
Remove song c - Change position of song s - Output songs by specific artist t - Output total time
of playlist (in seconds) o - Output full playlist q - Quit Choose an option: (4) Implement "Output
full playlist" menu option. If the list is empty, output: Playlist is empty (3 pts) Ex: JAMZ -
OUTPUT FULL PLAYLIST 1. Unique ID: SD123 Song Name: Peg Artist Name: Steely Dan
Song Length (in seconds): 237 2. Unique ID: JJ234 Song Name: All For You Artist Name: Janet
Jackson Song Length (in seconds): 391 3. Unique ID: J345 Song Name: Canned Heat Artist
Name: Jamiroquai Song Length (in seconds): 330 4. Unique ID: JJ456 Song Name: Black Eagle
Artist Name: Janet Jackson Song Length (in seconds): 197 5. Unique ID: SD567 Song Name: I
Got The News Artist Name: Steely Dan Song Length (in seconds): 306 (5) Implement the "Add
song" menu item. New additions are added to the end of the list. (2 pts) Ex: ADD SONG Enter
song's unique ID: SD123 Enter song's name: Peg Enter artist's name: Steely Dan Enter song's
length (in seconds): 237 (6) Implement the "Remove song" function. Prompt the user for the
unique ID of the song to be removed.(4 pts) Ex: REMOVE SONG Enter song's unique ID:
JJ234 "All For You" removed (7) Implement the "Change position of song" menu option.
Prompt the user for the current position of the song and the desired new position. Valid new
positions are 1 - n (the number of nodes). If the user enters a new position that is less than 1,
move the node to the position 1 (the head). If the user enters a new position greater than n, move
the node to position n (the tail). 6 cases will be tested: Moving the head node (1 pt) Moving the
tail node (1 pt) Moving a node to the head (1 pt) Moving a node to the tail (1 pt) Moving a node
up the list (1 pt) Moving a node down the list (1 pt) Ex: CHANGE POSITION OF SONG Enter
song's current position: 3 Enter new position for song: 2 "Canned Heat" moved to position 2
(8) Implement the "Output songs by specific artist" menu option. Prompt the user for the
artist's name, and output the node's information, starting with the node's current position. (2 pt)
Ex: OUTPUT SONGS BY SPECIFIC ARTIST Enter artist's name: Janet Jackson 2. Unique ID:
JJ234 Song Name: All For You Artist Name: Janet Jackson Song Length (in seconds): 391 4.
Unique ID: JJ456 Song Name: Black Eagle Artist Name: Janet Jackson Song Length (in
seconds): 197 (9) Implement the "Output total time of playlist" menu option. Output the sum of
the time of the playlist's songs (in seconds). (2 pts) Ex: OUTPUT TOTAL TIME OF
PLAYLIST (IN SECONDS) Total time: 1461 seconds
Solution
#include
#include
#include
#include
#include "songs.h"
using namespace std;
Songs::Songs()
{
this->songName = " ";
this->artistName = " ";
this->albumName = " ";
this->playTime = 1;
this->year = 1901;
this->starRating = 1;
this->genre = "Other";
}
Songs::Songs(string SN, string ArN, string AlN, int PT, int YR, int SR, string GR)
{
this->songName = SN;
this->artistName = ArN;
this->albumName = AlN;
this->playTime = PT;
this->year = YR;
this->starRating = SR;
this->genre = GR;
}
string Songs::getSongName()
{
return songName;
}
void Songs::setSongName(string newSong)
{
this->songName = newSong;
}
string Songs::getArtistName()
{
return artistName;
}
void Songs::setArtistName(string newArtist)
{
this->artistName = newArtist;
}
string Songs::getAlbumName()
{
return albumName;
}
void Songs::setAlbumName(string newAlbum)
{
this->albumName = newAlbum;
}
int Songs::getPlayTime()
{
return playTime;
}
void Songs::setPlayTime(int newTime)
{
this->playTime = newTime;
}
int Songs::getYear()
{
return year;
}
void Songs::setYear(int newYear)
{
this->year = newYear;
}
int Songs::getStarRating()
{
return starRating;
}
void Songs::setStarRating(int newStarRating)
{
this->starRating = newStarRating;
}
string Songs::getSongGenre()
{
return genre;
}
void Songs::setSongGenre(string newGenre)
{
this->genre = newGenre;
}
void Songs::addSongLibrary(vector *library, vector *playlist)
{
cout << "Please enter song name: ";
getline(cin, songName);
cout << "Please enter artist name: ";
getline(cin, artistName);
cout << "Please enter album name: ";
getline(cin, albumName);
while(true)
{
cout << "Please enter length of song in seconds: ";
cin >> playTime;
if(!cin.fail() && playTime > 0)
break;
else if(cin.fail())
cout << "Time must be in seconds. Please enter the song's length again: ";
else if(playTime <= 0)
cout << "Time must be greater than 0 seconds. Please enter the song's length again:
";
cin >> playTime;
}
while(true)
{
cout << "Please enter the year the song was made: ";
cin >> year;
if(!cin.fail() && year < 1900)
break;
else if(cin.fail())
cout << "Year must be in numbers. Please enter the song's year again: ";
else if(year < 1900)
cout << "Year must be 1900 or greater. Please enter the song's year again: ";
cin >> year;
}
while(true)
{
cout << "Please enter a star rating for the song (1 to 5 stars): ";
cin >> starRating;
if(!cin.fail() && starRating >= 1 && starRating <= 5)
break;
else if(cin.fail())
cout << "Rating can only be the digits 1, 2, 3, 4, or 5. Please enter a new rating for the
song: ";
else if(starRating < 1 || starRating > 5)
cout << "Rating must be between 1 and 5. Please enter the song's year again: ";
cin >> year;
}
while(true)
{
cout << "Please enter a genre (Rock, Rap, Country, Gospel, or Other) for the song: ";
cin >> genre;
if(genre == "Rock" || genre == "Rap" || genre == "Country" || genre == "Gospel" ||
genre == "Other")
break;
else
cout << "Genre not recognized. Please enter one of the five given genres (Rock, Rap,
Country, Gospel, or Other)";
cin >> genre;
}
Songs* newSongInfo = new Songs();
newSongInfo->setSongName(songName);
newSongInfo->setArtistName(artistName);
newSongInfo->setAlbumName(albumName);
newSongInfo->setPlayTime(playTime);
newSongInfo->setYear(year);
newSongInfo->setStarRating(starRating);
newSongInfo->setSongGenre(genre);
library.push_back(newSongInfo);
while(true)
{
cout << "Enter y to add the song to you playlist, or n to do nothing: ";
cin >> yesOrNo;
if(yesOrNo = 'y')
{
playlist.push_back(newSongInfo);
break;
}
else if(yesOrNo == 'n')
break;
else
cout << "Invalid operation. Please enter y to add the song to you playlist, or n to do
nothing: ";
cin >> yesOrNo;
}
}

More Related Content

Similar to 8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf

Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdf
fazanmobiles
 
Program 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfProgram 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdf
addtechglobalmarketi
 
Can someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdfCan someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdf
akshpatil4
 
Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdf
addtechglobalmarketi
 
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdfHi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
apleathers
 
Can someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdfCan someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdf
akshpatil4
 
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdfHere is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
ANANDSALESINDIA105
 
Exercise 3 You are to code some simple music player application .pdf
Exercise 3  You are to code some simple music player application .pdfExercise 3  You are to code some simple music player application .pdf
Exercise 3 You are to code some simple music player application .pdf
facevenky
 
816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.pdf816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.pdf
sastaindin
 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docx
jacksnathalie
 
It's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdfIt's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdf
aanyajoshi90
 
maincpp include ltiostreamgt include ltstringgt.pdf
maincpp  include ltiostreamgt include ltstringgt.pdfmaincpp  include ltiostreamgt include ltstringgt.pdf
maincpp include ltiostreamgt include ltstringgt.pdf
mukulsingh0025
 
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdfIn C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
shreeaadithyaacellso
 
PLEASE I need help with my assignment I have to compelet .pdf
PLEASE I need help with my assignment I have to compelet  .pdfPLEASE I need help with my assignment I have to compelet  .pdf
PLEASE I need help with my assignment I have to compelet .pdf
ankit11134
 
I need help writing test Codepackage org.example;import j.pdf
I need help writing test Codepackage org.example;import j.pdfI need help writing test Codepackage org.example;import j.pdf
I need help writing test Codepackage org.example;import j.pdf
mail931892
 
Problem 2 struct to hold information about a song struct So.pdf
 Problem 2 struct to hold information about a song struct So.pdf Problem 2 struct to hold information about a song struct So.pdf
Problem 2 struct to hold information about a song struct So.pdf
ahujaelectronics175
 
Cover Page & Table of Contents
Cover Page & Table of ContentsCover Page & Table of Contents
Cover Page & Table of Contents
Michael Peterson
 

Similar to 8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf (20)

Many of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdfMany of us have large digital music collections that are not always .pdf
Many of us have large digital music collections that are not always .pdf
 
Program 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdfProgram 02 Based on the previous problem you should impleme.pdf
Program 02 Based on the previous problem you should impleme.pdf
 
Can someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdfCan someone please help me implement the addSong function .pdf
Can someone please help me implement the addSong function .pdf
 
Program 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdfProgram 01 For this program you will complete the program in.pdf
Program 01 For this program you will complete the program in.pdf
 
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdfHi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
Hi,Please find the Ansswer below.PLAYLIST.h#include iostrea.pdf
 
Can someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdfCan someone please help me complete the add_song function .pdf
Can someone please help me complete the add_song function .pdf
 
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdfHere is the code.compile  g++ Playlist.cpp main.cppPlaylist.h.pdf
Here is the code.compile g++ Playlist.cpp main.cppPlaylist.h.pdf
 
Exercise 3 You are to code some simple music player application .pdf
Exercise 3  You are to code some simple music player application .pdfExercise 3  You are to code some simple music player application .pdf
Exercise 3 You are to code some simple music player application .pdf
 
816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.pdf816 LAB Playlist output linked list Hey I have most of.pdf
816 LAB Playlist output linked list Hey I have most of.pdf
 
OverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docxOverviewThis project will allow you to write a program to get mo.docx
OverviewThis project will allow you to write a program to get mo.docx
 
It's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdfIt's not working what am I doing wrong- Given main()- complete the Son.pdf
It's not working what am I doing wrong- Given main()- complete the Son.pdf
 
S3
S3S3
S3
 
In C++ Plz LAB- Playlist (output linked list) Given main()- complete.pdf
In C++ Plz  LAB- Playlist (output linked list) Given main()- complete.pdfIn C++ Plz  LAB- Playlist (output linked list) Given main()- complete.pdf
In C++ Plz LAB- Playlist (output linked list) Given main()- complete.pdf
 
maincpp include ltiostreamgt include ltstringgt.pdf
maincpp  include ltiostreamgt include ltstringgt.pdfmaincpp  include ltiostreamgt include ltstringgt.pdf
maincpp include ltiostreamgt include ltstringgt.pdf
 
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdfIn C++ Plz and In What Order Do I Put It In-  LAB- Playlist (output li.pdf
In C++ Plz and In What Order Do I Put It In- LAB- Playlist (output li.pdf
 
PLEASE I need help with my assignment I have to compelet .pdf
PLEASE I need help with my assignment I have to compelet  .pdfPLEASE I need help with my assignment I have to compelet  .pdf
PLEASE I need help with my assignment I have to compelet .pdf
 
Querier – simple relational database access
Querier – simple relational database accessQuerier – simple relational database access
Querier – simple relational database access
 
I need help writing test Codepackage org.example;import j.pdf
I need help writing test Codepackage org.example;import j.pdfI need help writing test Codepackage org.example;import j.pdf
I need help writing test Codepackage org.example;import j.pdf
 
Problem 2 struct to hold information about a song struct So.pdf
 Problem 2 struct to hold information about a song struct So.pdf Problem 2 struct to hold information about a song struct So.pdf
Problem 2 struct to hold information about a song struct So.pdf
 
Cover Page & Table of Contents
Cover Page & Table of ContentsCover Page & Table of Contents
Cover Page & Table of Contents
 

More from arenamobiles123

Describe how to use sanction such that a process can send a payload w.pdf
Describe how to use sanction such that a process can send a payload w.pdfDescribe how to use sanction such that a process can send a payload w.pdf
Describe how to use sanction such that a process can send a payload w.pdf
arenamobiles123
 
based on this evidence Syconoid sponges were derived from leuconoid.pdf
based on this evidence  Syconoid sponges were derived from leuconoid.pdfbased on this evidence  Syconoid sponges were derived from leuconoid.pdf
based on this evidence Syconoid sponges were derived from leuconoid.pdf
arenamobiles123
 
A) If a DNA double helix that is 100 base pairs in length has 32 a.pdf
A) If a DNA double helix that is 100 base pairs in length has 32 a.pdfA) If a DNA double helix that is 100 base pairs in length has 32 a.pdf
A) If a DNA double helix that is 100 base pairs in length has 32 a.pdf
arenamobiles123
 
Chapter2...22.            (Problem 3) Which of the following are.pdf
Chapter2...22.            (Problem 3) Which of the following are.pdfChapter2...22.            (Problem 3) Which of the following are.pdf
Chapter2...22.            (Problem 3) Which of the following are.pdf
arenamobiles123
 
Write a program that takes any input text and produces both a frequen.pdf
Write a program that takes any input text and produces both a frequen.pdfWrite a program that takes any input text and produces both a frequen.pdf
Write a program that takes any input text and produces both a frequen.pdf
arenamobiles123
 
why is reversibility an important characteristic of childrens .pdf
why is reversibility an important characteristic of childrens .pdfwhy is reversibility an important characteristic of childrens .pdf
why is reversibility an important characteristic of childrens .pdf
arenamobiles123
 
What are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdf
What are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdfWhat are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdf
What are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdf
arenamobiles123
 
Which key numbers help you asses your performance in an organizat.pdf
Which key numbers help you asses your performance in an organizat.pdfWhich key numbers help you asses your performance in an organizat.pdf
Which key numbers help you asses your performance in an organizat.pdf
arenamobiles123
 
Social behavior in termites does not include the reproductive isolat.pdf
Social behavior in termites does not include the reproductive isolat.pdfSocial behavior in termites does not include the reproductive isolat.pdf
Social behavior in termites does not include the reproductive isolat.pdf
arenamobiles123
 
Sam, a 27-year-old African-American male, was admitted to the hospit.pdf
Sam, a 27-year-old African-American male, was admitted to the hospit.pdfSam, a 27-year-old African-American male, was admitted to the hospit.pdf
Sam, a 27-year-old African-American male, was admitted to the hospit.pdf
arenamobiles123
 

More from arenamobiles123 (20)

Consider the following experiment. There are 5 members of a team Jo.pdf
Consider the following experiment. There are 5 members of a team Jo.pdfConsider the following experiment. There are 5 members of a team Jo.pdf
Consider the following experiment. There are 5 members of a team Jo.pdf
 
A prolific couple had ten children.Through hard work and diligence a.pdf
A prolific couple had ten children.Through hard work and diligence a.pdfA prolific couple had ten children.Through hard work and diligence a.pdf
A prolific couple had ten children.Through hard work and diligence a.pdf
 
Describe how to use sanction such that a process can send a payload w.pdf
Describe how to use sanction such that a process can send a payload w.pdfDescribe how to use sanction such that a process can send a payload w.pdf
Describe how to use sanction such that a process can send a payload w.pdf
 
based on this evidence Syconoid sponges were derived from leuconoid.pdf
based on this evidence  Syconoid sponges were derived from leuconoid.pdfbased on this evidence  Syconoid sponges were derived from leuconoid.pdf
based on this evidence Syconoid sponges were derived from leuconoid.pdf
 
At noon Joyce drove to the lake at 30 miles per hour, but she made t.pdf
At noon Joyce drove to the lake at 30 miles per hour, but she made t.pdfAt noon Joyce drove to the lake at 30 miles per hour, but she made t.pdf
At noon Joyce drove to the lake at 30 miles per hour, but she made t.pdf
 
A) If a DNA double helix that is 100 base pairs in length has 32 a.pdf
A) If a DNA double helix that is 100 base pairs in length has 32 a.pdfA) If a DNA double helix that is 100 base pairs in length has 32 a.pdf
A) If a DNA double helix that is 100 base pairs in length has 32 a.pdf
 
Chapter2...22.            (Problem 3) Which of the following are.pdf
Chapter2...22.            (Problem 3) Which of the following are.pdfChapter2...22.            (Problem 3) Which of the following are.pdf
Chapter2...22.            (Problem 3) Which of the following are.pdf
 
Write a program that takes any input text and produces both a frequen.pdf
Write a program that takes any input text and produces both a frequen.pdfWrite a program that takes any input text and produces both a frequen.pdf
Write a program that takes any input text and produces both a frequen.pdf
 
why is reversibility an important characteristic of childrens .pdf
why is reversibility an important characteristic of childrens .pdfwhy is reversibility an important characteristic of childrens .pdf
why is reversibility an important characteristic of childrens .pdf
 
Which of the following tools is used to generate the profiles and se.pdf
Which of the following tools is used to generate the profiles and se.pdfWhich of the following tools is used to generate the profiles and se.pdf
Which of the following tools is used to generate the profiles and se.pdf
 
What are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdf
What are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdfWhat are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdf
What are 2 ways that Alexander Hamilton’s ideas influenced the Unite.pdf
 
Which of the following is a non-respiratory function of the lunga.pdf
Which of the following is a non-respiratory function of the lunga.pdfWhich of the following is a non-respiratory function of the lunga.pdf
Which of the following is a non-respiratory function of the lunga.pdf
 
Which key numbers help you asses your performance in an organizat.pdf
Which key numbers help you asses your performance in an organizat.pdfWhich key numbers help you asses your performance in an organizat.pdf
Which key numbers help you asses your performance in an organizat.pdf
 
what two things can system elements do with energy in the system.pdf
what two things can system elements do with energy in the system.pdfwhat two things can system elements do with energy in the system.pdf
what two things can system elements do with energy in the system.pdf
 
What is an Intervening Variable, Casual Prior Variable, and Partial .pdf
What is an Intervening Variable, Casual Prior Variable, and Partial .pdfWhat is an Intervening Variable, Casual Prior Variable, and Partial .pdf
What is an Intervening Variable, Casual Prior Variable, and Partial .pdf
 
The basic functional plan of the gonads includes all of the followin.pdf
The basic functional plan of the gonads includes all of the followin.pdfThe basic functional plan of the gonads includes all of the followin.pdf
The basic functional plan of the gonads includes all of the followin.pdf
 
The color of the small lymphocytes cytoplasm is a very () lilac a.pdf
The color of the small lymphocytes cytoplasm is a very () lilac a.pdfThe color of the small lymphocytes cytoplasm is a very () lilac a.pdf
The color of the small lymphocytes cytoplasm is a very () lilac a.pdf
 
Social behavior in termites does not include the reproductive isolat.pdf
Social behavior in termites does not include the reproductive isolat.pdfSocial behavior in termites does not include the reproductive isolat.pdf
Social behavior in termites does not include the reproductive isolat.pdf
 
Sam, a 27-year-old African-American male, was admitted to the hospit.pdf
Sam, a 27-year-old African-American male, was admitted to the hospit.pdfSam, a 27-year-old African-American male, was admitted to the hospit.pdf
Sam, a 27-year-old African-American male, was admitted to the hospit.pdf
 
question 4) Which of following elements are nonmetals Na O Ar S .pdf
question 4) Which of following elements are nonmetals Na O Ar S .pdfquestion 4) Which of following elements are nonmetals Na O Ar S .pdf
question 4) Which of following elements are nonmetals Na O Ar S .pdf
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
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
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

8.15 Program Playlist (C++) You will be building a linked list. Mak.pdf

  • 1. 8.15 Program: Playlist (C++) You will be building a linked list. Make sure to keep track of both the head and tail nodes. (1) Create three files to submit. Playlist.h - Class declaration Playlist.cpp - Class definition main.cpp - main() function Build the PlaylistNode class per the following specifications. Note: Some functions can initially be function stubs (empty functions), to be completed in later steps. Default constructor (1 pt) Parameterized constructor (1 pt) Public member functions InsertAfter() (1 pt) SetNext() - Mutator (1 pt) GetID() - Accessor GetSongName() - Accessor GetArtistName() - Accessor GetSongLength() - Accessor GetNext() - Accessor PrintPlaylistNode() Private data members string uniqueID - Initialized to "none" in default constructor string songName - Initialized to "none" in default constructor string artistName - Initialized to "none" in default constructor int songLength - Initialized to 0 in default constructor PlaylistNode* nextNodePtr - Initialized to 0 in default constructor Ex. of PrintPlaylistNode output: Unique ID: S123 Song Name: Peg Artist Name: Steely Dan Song Length (in seconds): 237 (2) In main(), prompt the user for the title of the playlist. (1 pt) Ex: Enter playlist's title: JAMZ (3) Implement the PrintMenu() function. PrintMenu() takes the playlist title as a parameter and outputs a menu of options to manipulate the playlist. Each option is represented by a single character. Build and output the menu within the function. If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call PrintMenu() in the main() function. Continue to execute the menu until the user enters q to Quit. (3 pts) Ex: JAMZ PLAYLIST MENU a - Add song d - Remove song c - Change position of song s - Output songs by specific artist t - Output total time of playlist (in seconds) o - Output full playlist q - Quit Choose an option: (4) Implement "Output full playlist" menu option. If the list is empty, output: Playlist is empty (3 pts) Ex: JAMZ - OUTPUT FULL PLAYLIST 1. Unique ID: SD123 Song Name: Peg Artist Name: Steely Dan Song Length (in seconds): 237 2. Unique ID: JJ234 Song Name: All For You Artist Name: Janet Jackson Song Length (in seconds): 391 3. Unique ID: J345 Song Name: Canned Heat Artist Name: Jamiroquai Song Length (in seconds): 330 4. Unique ID: JJ456 Song Name: Black Eagle Artist Name: Janet Jackson Song Length (in seconds): 197 5. Unique ID: SD567 Song Name: I Got The News Artist Name: Steely Dan Song Length (in seconds): 306 (5) Implement the "Add song" menu item. New additions are added to the end of the list. (2 pts) Ex: ADD SONG Enter song's unique ID: SD123 Enter song's name: Peg Enter artist's name: Steely Dan Enter song's length (in seconds): 237 (6) Implement the "Remove song" function. Prompt the user for the unique ID of the song to be removed.(4 pts) Ex: REMOVE SONG Enter song's unique ID: JJ234 "All For You" removed (7) Implement the "Change position of song" menu option. Prompt the user for the current position of the song and the desired new position. Valid new positions are 1 - n (the number of nodes). If the user enters a new position that is less than 1,
  • 2. move the node to the position 1 (the head). If the user enters a new position greater than n, move the node to position n (the tail). 6 cases will be tested: Moving the head node (1 pt) Moving the tail node (1 pt) Moving a node to the head (1 pt) Moving a node to the tail (1 pt) Moving a node up the list (1 pt) Moving a node down the list (1 pt) Ex: CHANGE POSITION OF SONG Enter song's current position: 3 Enter new position for song: 2 "Canned Heat" moved to position 2 (8) Implement the "Output songs by specific artist" menu option. Prompt the user for the artist's name, and output the node's information, starting with the node's current position. (2 pt) Ex: OUTPUT SONGS BY SPECIFIC ARTIST Enter artist's name: Janet Jackson 2. Unique ID: JJ234 Song Name: All For You Artist Name: Janet Jackson Song Length (in seconds): 391 4. Unique ID: JJ456 Song Name: Black Eagle Artist Name: Janet Jackson Song Length (in seconds): 197 (9) Implement the "Output total time of playlist" menu option. Output the sum of the time of the playlist's songs (in seconds). (2 pts) Ex: OUTPUT TOTAL TIME OF PLAYLIST (IN SECONDS) Total time: 1461 seconds Solution #include #include #include #include #include "songs.h" using namespace std; Songs::Songs() { this->songName = " "; this->artistName = " "; this->albumName = " "; this->playTime = 1; this->year = 1901; this->starRating = 1; this->genre = "Other"; } Songs::Songs(string SN, string ArN, string AlN, int PT, int YR, int SR, string GR) { this->songName = SN; this->artistName = ArN;
  • 3. this->albumName = AlN; this->playTime = PT; this->year = YR; this->starRating = SR; this->genre = GR; } string Songs::getSongName() { return songName; } void Songs::setSongName(string newSong) { this->songName = newSong; } string Songs::getArtistName() { return artistName; } void Songs::setArtistName(string newArtist) { this->artistName = newArtist; } string Songs::getAlbumName() { return albumName; } void Songs::setAlbumName(string newAlbum) { this->albumName = newAlbum; } int Songs::getPlayTime() { return playTime; } void Songs::setPlayTime(int newTime) {
  • 4. this->playTime = newTime; } int Songs::getYear() { return year; } void Songs::setYear(int newYear) { this->year = newYear; } int Songs::getStarRating() { return starRating; } void Songs::setStarRating(int newStarRating) { this->starRating = newStarRating; } string Songs::getSongGenre() { return genre; } void Songs::setSongGenre(string newGenre) { this->genre = newGenre; } void Songs::addSongLibrary(vector *library, vector *playlist) { cout << "Please enter song name: "; getline(cin, songName); cout << "Please enter artist name: "; getline(cin, artistName); cout << "Please enter album name: "; getline(cin, albumName); while(true) {
  • 5. cout << "Please enter length of song in seconds: "; cin >> playTime; if(!cin.fail() && playTime > 0) break; else if(cin.fail()) cout << "Time must be in seconds. Please enter the song's length again: "; else if(playTime <= 0) cout << "Time must be greater than 0 seconds. Please enter the song's length again: "; cin >> playTime; } while(true) { cout << "Please enter the year the song was made: "; cin >> year; if(!cin.fail() && year < 1900) break; else if(cin.fail()) cout << "Year must be in numbers. Please enter the song's year again: "; else if(year < 1900) cout << "Year must be 1900 or greater. Please enter the song's year again: "; cin >> year; } while(true) { cout << "Please enter a star rating for the song (1 to 5 stars): "; cin >> starRating; if(!cin.fail() && starRating >= 1 && starRating <= 5) break; else if(cin.fail()) cout << "Rating can only be the digits 1, 2, 3, 4, or 5. Please enter a new rating for the song: "; else if(starRating < 1 || starRating > 5) cout << "Rating must be between 1 and 5. Please enter the song's year again: "; cin >> year; }
  • 6. while(true) { cout << "Please enter a genre (Rock, Rap, Country, Gospel, or Other) for the song: "; cin >> genre; if(genre == "Rock" || genre == "Rap" || genre == "Country" || genre == "Gospel" || genre == "Other") break; else cout << "Genre not recognized. Please enter one of the five given genres (Rock, Rap, Country, Gospel, or Other)"; cin >> genre; } Songs* newSongInfo = new Songs(); newSongInfo->setSongName(songName); newSongInfo->setArtistName(artistName); newSongInfo->setAlbumName(albumName); newSongInfo->setPlayTime(playTime); newSongInfo->setYear(year); newSongInfo->setStarRating(starRating); newSongInfo->setSongGenre(genre); library.push_back(newSongInfo); while(true) { cout << "Enter y to add the song to you playlist, or n to do nothing: "; cin >> yesOrNo; if(yesOrNo = 'y') { playlist.push_back(newSongInfo); break; } else if(yesOrNo == 'n') break; else cout << "Invalid operation. Please enter y to add the song to you playlist, or n to do
  • 7. nothing: "; cin >> yesOrNo; } }