Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 0 . 2 2 CIST 2 3 6 2 LAB: Playlist ( output linked list ) Given main ( ) , complete the SongNode
CIST 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!
The Brothers Johnson
The Dude
Quincy Jones
You Don't Own Me
Lesley Gore
the output is:
LIST OF SONGS
Title: Stomp!
Length:
Artist: The Brothers Johnson
Title: The Dude
Length:
Artist: Quincy Jones
Title: You Don't Own Me
Length:
Artist: Lesley Gore
Here is the code that must be used:
main.cpp:
#include
#include "SongNode.h
TODO: Write PrintPlaylist function
int main
SongNode headNode;
SongNode currNode;
SongNode lastNode;
string songTitle;
string songLength;
string songArtist;
Front of nodes list
headNode new SongNode;
lastNode headNode;
Read user input until entered
getlinecin songTitle;
while songTitle
getlinecin songLength;
getlinecin songArtist;
currNode new SongNodesongTitle songLength, songArtist;
lastNodeInsertAftercurrNode;
lastNode currNode;
getlinecin songTitle;
Print linked list
cout "LIST OF SONGS" endl;
cout endl;
PrintPlaylistheadNode;
return ;
SongNode.cpp:
#include "SongNode.h
Constructor
SongNode::SongNodestring songTitleInit, string songLengthInit, string songArtistInit
thissongTitle songTitleInit;
thissongLength songLengthInit;
thissongArtist songArtistInit;
thisnextNodeRef NULL;
Constructor
SongNode::SongNodestring songTitleInit, string songLengthInit, string songArtistInit, SongNode nextLoc
thissongTitle songTitleInit;
thissongLength songLengthInit;
thissongArtist songArtistInit;
thisnextNodeRef nextLoc;
insertAfter
void SongNode::InsertAfterSongNode nodeLoc
SongNode tmpNext;
tmpNext thisnextNodeRef;
thisnextNodeRef nodeLoc;
nodeLocnextNodeRef tmpNext;
Get location pointed by nextNodeRef
SongNode SongNode::GetNext
return thisnextNodeRef;
TODO: Write PrintSongInfo function
SongNode.h:
#include "iostream"
#include
using namespace std;
class SongNode
private:
string songTitle;
string songLength;
string songArtist;
SongNode nextNodeRef; Reference to the next node
public:
SongNode
songTitle ;
songLength ;
songArtist ;
nextNodeRef NULL;
Constructor
SongNodestring songTitleInit, string songLengthInit, string songArtistInit;
Constructor
SongNodestring songTitleInit, string songLengthInit, string songArtistInit, SongNode nextLoc;
insertAfter
void InsertAfterSongNode nodeLoc;
Get location pointed by nextNodeRef
SongNode GetNext;
Prints song information
void PrintSongInfo;
;
In C please!
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