Question: Pls Help The yellow highlight is a part i need to fix! Main.cpp #include #include #include PlaylistNode.h using namespace std; // function declaration char PrintMenu(string

Pls Help The yellow highlight is a part i need to fix!

Main.cpp

#include #include #include "PlaylistNode.h" using namespace std;

// function declaration char PrintMenu(string playlistTitle); void AddSong(PlaylistNode*& head, PlaylistNode*& tail); void RemoveSong(PlaylistNode*& head, PlaylistNode*& tail); void MoveSong(PlaylistNode*& head, PlaylistNode*& tail); void SpecificArtistSong(PlaylistNode* head, PlaylistNode* tail);

int main() { string playlistTitle; PlaylistNode *head = NULL, *tail = NULL; char choice;

// input the name of play list cout

// loop that continues until the user exits do { choice = PrintMenu(playlistTitle); if(choice == 'a') { AddSong(head, tail); } else if(choice == 'd') { RemoveSong(head, tail); } else if(choice == 'c') { MoveSong(head, tail); } else if(choice == 's') { SpecificArtistSong(head, tail); } else if(choice == 't') { cout

// loop over the list to calculate the total time of all songs while(curr != NULL) { total_time += curr->GetSongLength(); curr = curr->GetNext(); } cout

// loop over the list, displaying each song while(curr != NULL) { coutPrintPlaylistNode(); coutGetNext(); pos++; } } } cout

return 0; }

// function to display the menu, input the user choice and return it char PrintMenu(string playlistTitle) { char option; cout>option; option = tolower(option);

// loop that continues until user enters a valid option while(option != 'a' && option != 'd' && option != 'c' && option != 's' && option != 't' && option != 'o' && option != 'q') { cout>option; option = tolower(option); }

return option; }

// function to add a song at the end of the list void AddSong(PlaylistNode*& head, PlaylistNode*& tail) { string uniqueID; string songName ; string artistName; int songLength; cout

// input song details cout>uniqueID; cout>songLength;

if(head == NULL) // empty list, create a new head node and set tail node to head { head = new PlaylistNode(uniqueID, songName, artistName, songLength);; tail = head; } else{ // insert the song after tail tail->InsertAfter(uniqueID, songName, artistName, songLength); tail = tail->GetNext(); // update tail to the new node created } }

// function to remove a song from the list void RemoveSong(PlaylistNode*& head, PlaylistNode*& tail) { string uniqueID; cout

// input song ID cout>uniqueID;

if(head != NULL) // non-empty list { PlaylistNode *curr = head; PlaylistNode *prev = NULL;

// loop to get and remove the node with ID while(curr != NULL) { if(curr->GetID() == uniqueID) // song found { if(prev == NULL){ // remove head node head = head->GetNext(); if(head == NULL) // empty list after removal tail = NULL; } else{ prev->SetNext(curr->GetNext()); if(prev->GetNext() == NULL) // last node removed, update tail to prev tail = prev; }

coutGetSongName()

// remove current node curr->SetNext(NULL); delete curr; curr = NULL; return; }

prev = curr; curr = curr->GetNext(); } }

cout

// function to change the position of a song void MoveSong(PlaylistNode*& head, PlaylistNode*& tail) { cout

// input the current and new position cout>curr_pos; cout>new_pos;

int n = 0; PlaylistNode *curr = head; // loop to calculate the number of songs in the list while(curr != NULL) { n++; curr = curr->GetNext(); }

// validate current position if(curr_pos > 0 && curr_pos

// update new_pos to valid position if(new_pos n) new_pos = n;

if(curr_pos != new_pos) // curr_pos and new_pos are not same { PlaylistNode* current; curr = head; PlaylistNode* prev = NULL;

int pos = 0;

// get the node to change while(curr != NULL) { pos++; if(pos == curr_pos) { // remove the current node from current position current = curr; if(prev == NULL){ head = curr->GetNext(); if(head->GetNext() == NULL) tail = head; } else{ prev->SetNext(curr->GetNext()); if(prev->GetNext() == NULL) tail = prev; } break; }

prev = curr; curr = curr->GetNext(); }

current->SetNext(NULL);

// get the node where to insert curr = head; prev = NULL;

pos = 1; while((curr != NULL) && (pos != new_pos)) { prev = curr; curr = curr->GetNext(); pos++; }

// insert the node in new position current->SetNext(curr); if(prev == NULL) { head = current; }else if(prev->GetNext() == NULL) { tail->SetNext(current); tail = current; }else prev->SetNext(current);

coutGetSongName()

// function to display the songs from a given artist void SpecificArtistSong(PlaylistNode* head, PlaylistNode* tail) { string artistName; cout

// input artist name cout

PlaylistNode *curr = head; int pos = 1;

// loop over the list, displaying the songs by the given artist while(curr != NULL) { if(curr->GetArtistName() == artistName){ coutPrintPlaylistNode(); coutGetNext(); pos++; } }

************************************************************************

PlaylistNode.cpp :

#include "PlaylistNode.h" #include

// default constructor PlaylistNode::PlaylistNode() : uniqueID("none"), songName("none"), artistName("none"), songLength(0), nextNodePtr(0) {}

// Parameterized constructor PlaylistNode::PlaylistNode(string ID, string sname, string aname, int len) : uniqueID(ID), songName(sname), artistName(aname), songLength(len), nextNodePtr(0) {}

// function to insert the given song after this node void PlaylistNode:: InsertAfter(string ID,string sname,string aname,int len) { // create a new node to store the input song details PlaylistNode* node = new PlaylistNode(ID,sname,aname,len); node->SetNext(this->nextNodePtr); // update node's next to next of this song this->nextNodePtr = node; // update next of this song to node }

// updates the nextNodePtr pointer of this node to next void PlaylistNode:: SetNext(PlaylistNode *node) { nextNodePtr = node; }

// returns the songID string PlaylistNode:: GetID() { return uniqueID; }

// return the song name string PlaylistNode:: GetSongName() { return songName; }

// return the artist name string PlaylistNode:: GetArtistName() { return artistName; }

// return the song length int PlaylistNode:: GetSongLength() { return songLength; }

// return the nextNodePtr PlaylistNode* PlaylistNode:: GetNext() { return nextNodePtr; }

// function to display the song details void PlaylistNode::PrintPlaylistNode() { cout

*-*********************************************************************************

PlaylistNode.h

#ifndef PLAYLISTNODE_H #define PLAYLISTNODE_H

#include using namespace std;

class PlaylistNode { private: string uniqueID; // unique ID of the song string songName ; // name of the song string artistName; // artist of the song int songLength; // length of song in seconds PlaylistNode* nextNodePtr; // pointer to next song in the list

public: PlaylistNode(); PlaylistNode(string ID, string sname, string aname, int len); void InsertAfter(string ID,string sname,string aname,int len); void SetNext(PlaylistNode *node); string GetID(); string GetSongName(); string GetArtistName(); int GetSongLength(); PlaylistNode* GetNext(); void PrintPlaylistNode();

};

#endif

*****************************************************************************

The Problem:

Pls Help The yellow highlight is a part i need toPls Help The yellow highlight is a part i need toPls Help The yellow highlight is a part i need toPls Help The yellow highlight is a part i need toPls Help The yellow highlight is a part i need to
2:Unit test A 0/1 Tests that InsertAfter() correctly inserts "All For You"s node after "Peg"s node Compilation failed main. cpp: In function 'bool testPassed (std: : ofstreams) ' : main . cpp: 26:34: error: no matching function for call to 'playlistNode: : In 26 headNode->InsertAfter (nextNode); Compilation failed In file included from main. cpp: 4: PlaylistNode . h: 19:6: note: candidate: `void PlaylistNode: : InsertAfter (std 19 | void InsertAfter (string ID, string sname, string aname, int len) ; PlaylistNode . h : 19:6: note: candidate expects 4 arguments, 1 provided 3:Unit test A 1/ 1 Tests that SetNext() correctly sets "Canned Heat" to be "All For You's next node Test feedback SetNext () correctly sets next node. 4:Unit test A 1 /1 Tests that the default constructor initializes node correctly and accessors return correctly Test feedback Default constructor correctly initialized node and accessors return the co 5:Unit test A 0/1 Test PrintMenu("JAMZ"). Should output the menu options. Returned unexpected error code (-9)8:Unit test A 0 /1 Test ExecuteMenu('o', "JAMZ", headNode). Should output "JAMZ - OUTPUT FULL PLAYLIST Playlist is empty" Compilation failed main. cpp: In function 'bool testPassed (std: : ofstreams) ' : main . cpp: 38:4: error: 'ExecuteMenu' was not declared in this scope 38 1 ExecuteMenu (userOption, playlistTitle, headNode) ; Compilation failed ANNANNNNNNN main . cpp: 46:20: warning: comparison of integer expressions of different s 46 1 for (i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!