Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8.17 LAB: Playlist (output linked list) Given main(), complete the SongNode class to include the function PrintSonginfo(). Then write the PrintPlaylist() function in main.cpp to

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
8.17 LAB: Playlist (output linked list) Given main(), complete the SongNode class to include the function PrintSonginfo(). Then write the PrintPlaylist() function in main.cpp to print all songs in the playlist. DO NOT print the dummy head node. Ex: If the input is: Stomp ! 380 The Brothers Johnson The Dude 337 Quincy Jones You Don't Own Me 151 Lesley Gore -1 the output is: LIST OF SONGS Title: Stomp! Length: 380 Artist: The Brothers Johnson Title: The Dude Length: 337 Artist: Quincy Jones Title: You Don't Own Me Length: 151 Artist: Lesley Gore 464730.3214874.4x32gy7 LAB 8.17.1: LAB: Playlist (output linked list) 0 / 10 ACTIVITY Scanned with CamScanner Current file and dofault templateLAB ACTIVITY 8.17.1: LAB: Playlist (output linked list) 0 / 10 Current file: main.cpp Load default template... 1 #include #include "SongNode. h" // TODO: Write PrintPlaylist( ) function int main ( ) { SongNode* headNode; SongNode* currNode ; SongNode* lastNode; 10 11 string songTitle; 12 string songLength; 13 string songArtist; 14 15 // Front of nodes list 16 headNode = new SongNode ( ) ; 17 lastNode = headNode; 18 Run your program as often as you'd like, before submitting for grading. Below, type any needed Develop mode Submit mode input values in the first box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Run program Input (from above) main.cpp Output (shown below)LAB 0 / 10 ACTIVITY 8.17.1: LAB: Playlist (output linked list) Load default template... Current file: main.cpp ~ 21 while (songTitle != "-1") { 22 getline(cin, songLength) ; 23 getline(cin, songArtist) ; 24 25 currNode = new SongNode ( songTitle, songLength, songArtist) ; 26 lastNode ->InsertAfter (currNode ) ; 27 lastNode = currNode; 28 29 getline(cin, songTitle) ; 30 31 32 // Print linked list 33 cout IDWNH using namespace std; 5 class SongNode { 7 private: 8 string songTitle; 9 string songLength; 10 string songArtist; 11 SongNode* nextNodeRef; // Reference to the next node 12 13 public: 14 SongNode ( ) { 15 songTitle = "I. 16 songLength = "". 17 songArtist = "!. 18 nextNodeRef = NULL; Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the CS Scanners second box. anher Enter program input (optional) If your ando ranifires innit vallibe provide them hereCurrent file: SongNode.h Load default template... 18 nextNodeRef = NULL; 19 20 21 // Constructor 22 SongNode (string songTitleInit, string songLengthInit, string songArtistInit); 23 24 // Constructor 25 SongNode (string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc) ; 26 27 // insertAfter 28 void InsertAfter (SongNode* nodeLoc) ; 29 30 // Get location pointed by nextNodeRef 31 SongNode* GetNext ( ) ; 32 33 // Prints song information 34 void PrintSongInfo ( ) ; 35 };1 velop mode Submit mode R. in you program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box.Current file: SongNode.cpp Load default template... #include "SongNode .h" / / Constructor 4 SongNode : : SongNode (string songTitleInit, string songLengthInit, string songArtistInit) { 5 this->songTitle = songTitleInit; 6 this->songLength = songLengthInit; this->songArtist = songArtistInit; 8 this->nextNodeRef = NULL; 9 10 11 // Constructor 12 SongNode : : SongNode (string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc) { 13 this->songTitle = songTitleInit; 14 this->songLength = songLengthInit; 15 this->songArtist = songArtistInit; 16 this->nextNodeRef = nextLoc; 17 } 18 Run your program as often as you'd like, before submitting for grading. Below, type any needed Submit mc de in) it valdes, in me first box, then click Run program and observe the program's output in the second box.Current file: SongNode.cpp ~ Load default template... 15 this->songArtist = songArtistInit; 16 this->nextNodeRef = nextLoc; 17 } 18 19 // insertAfter 20 void SongNode : : InsertAfter ( SongNode* nodeLoc ) { 21 SongNode* tmpNext; 22 tmpNext = this->nextNodeRef; 23 this->nextNodeRef = nodeLoc; 24 nodeLoc->nextNodeRef = tmpNext ; 25 } 26 27 // Get location pointed by nextNodeRef 28 SongNode* SongNode : : GetNext ( ) { 29 return this->nextNodeRef; 30 } 31 32 // TODO: Write PrintSongInfo( ) function Run your program as often as you'd like, before submitting for grading. Below, type any needed Develop mode Submit mode input values in the first box, then click Run program and observe the program's output in the CS Scanned Enter program input (optional)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

All text files are technically also binary files. True or false?

Answered: 1 week ago