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. main.cc   #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 -1  entered     getline(cin, songTitle);     while (songTitle != "-1") {         getline(cin, songLength);         getline(cin, songArtist);         currNode = new SongNode(songTitle, songLength, songArtist);         lastNode->InsertAfter(currNode);         lastNode = currNode;         getline(cin, songTitle);     }     // Print linked list     cout << "LIST OF SONGS" << endl;     cout << "-------------" << endl;     PrintPlaylist(headNode);     return 0; } 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                                                                                          SongNode(string songTitleInit, string songLengthInit, string songArtistInit);     // Constructor                                                                                          SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc);     // insertAfter     void InsertAfter(SongNode* nodeLoc);     // Get location pointed by nextNodeRef                                                                 SongNode* GetNext();        // Prints song information        void PrintSongInfo(); }; SongNode.cpp #include "SongNode.h" // Constructor                                                                                      SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) {     this->songTitle = songTitleInit;     this->songLength = songLengthInit;     this->songArtist = songArtistInit;     this->nextNodeRef = NULL; } // Constructor                                                                                      SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc) {     this->songTitle = songTitleInit;     this->songLength = songLengthInit;     this->songArtist = songArtistInit;     this->nextNodeRef = nextLoc; } // insertAfter void SongNode::InsertAfter(SongNode* nodeLoc) {     SongNode* tmpNext;     tmpNext = this->nextNodeRef;     this->nextNodeRef = nodeLoc;     nodeLoc->nextNodeRef = tmpNext; } // Get location pointed by nextNodeRef                                                             SongNode* SongNode::GetNext() {     return this->nextNodeRef; } // TODO: Write PrintSongInfo() function PLEASE DO IN TO DO AND WRITE CODE C++. WRITE TEST INPUT SAME Expected output PLEASE

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

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.

main.cc

 

#include <iostream>
#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 -1  entered
    getline(cin, songTitle);
    while (songTitle != "-1") {
        getline(cin, songLength);
        getline(cin, songArtist);

        currNode = new SongNode(songTitle, songLength, songArtist);
        lastNode->InsertAfter(currNode);
        lastNode = currNode;

        getline(cin, songTitle);
    }

    // Print linked list
    cout << "LIST OF SONGS" << endl;
    cout << "-------------" << endl;
    PrintPlaylist(headNode);
    return 0;
}

SongNode.h

 

#include "iostream"
#include <string>

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                                                                                     
    SongNode(string songTitleInit, string songLengthInit, string songArtistInit);

    // Constructor                                                                                     
    SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc);

    // insertAfter
    void InsertAfter(SongNode* nodeLoc);

    // Get location pointed by nextNodeRef                                                            
    SongNode* GetNext();
   
   // Prints song information   
    void PrintSongInfo();
};

SongNode.cpp

#include "SongNode.h"

// Constructor                                                                                     
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit) {
    this->songTitle = songTitleInit;
    this->songLength = songLengthInit;
    this->songArtist = songArtistInit;
    this->nextNodeRef = NULL;
}

// Constructor                                                                                     
SongNode::SongNode(string songTitleInit, string songLengthInit, string songArtistInit, SongNode* nextLoc) {
    this->songTitle = songTitleInit;
    this->songLength = songLengthInit;
    this->songArtist = songArtistInit;
    this->nextNodeRef = nextLoc;
}

// insertAfter
void SongNode::InsertAfter(SongNode* nodeLoc) {
    SongNode* tmpNext;
    tmpNext = this->nextNodeRef;
    this->nextNodeRef = nodeLoc;
    nodeLoc->nextNodeRef = tmpNext;
}

// Get location pointed by nextNodeRef                                                            
SongNode* SongNode::GetNext() {
    return this->nextNodeRef;
}

// TODO: Write PrintSongInfo() function

PLEASE DO IN TO DO AND WRITE CODE C++. WRITE TEST INPUT SAME Expected output PLEASE

Output is nearly correct; but whitespace differs. See highlights belo
Stomp!
380
The Brothers Johnson
The Dude
337
Input
Quincy Jones
You Don't Own Me
151
Lesley Gore
-1
LIST OF SONGS
Title: Stomp!
Length: 380
Artist: The Brothers Johnson
Your output
Title: The Dude
Length: 337
Artist: Quincy Jones
Title: You Don't Own Me
Length: 151
Artist: Lesley Gore
Transcribed Image Text:Output is nearly correct; but whitespace differs. See highlights belo Stomp! 380 The Brothers Johnson The Dude 337 Input Quincy Jones You Don't Own Me 151 Lesley Gore -1 LIST OF SONGS Title: Stomp! Length: 380 Artist: The Brothers Johnson Your output Title: The Dude Length: 337 Artist: Quincy Jones Title: You Don't Own Me Length: 151 Artist: Lesley Gore
LIST OF SONGS
Title: Stomp!
Length: 380
Artist: The Brothers Johnson
Expected output
Title: The Dude
Length: 337
Artist: Quincy Jones
Title: You Don't Own Me
Length: 151
Artist: Lesley Gore
Transcribed Image Text:LIST OF SONGS Title: Stomp! Length: 380 Artist: The Brothers Johnson Expected output Title: The Dude Length: 337 Artist: Quincy Jones Title: You Don't Own Me Length: 151 Artist: Lesley Gore
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Linked List Representation
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education