Provide full C++ code Building a playlist (of songs) using a linked list and making some operations such as adding songs, removing songs, shuffling them, etc. (Some parts of this lab will closely follow lab 08 - it is imperative that you complete that lab before working on this project). A Node representing a song has the following data members (similar to struct Node of lab 08, except it doesn't have one member for storing data): string uniqueID string songName string artistName int songLength Node* nextNodePtr Your code must have the following three files: Playlist.h - Class declaration for a linked list of Nodes (very similar to lab 08 but with some changes to methods, as described below) with following private data members: private: Node* first; Node* last; int size; Playlist.cpp - Class definition main.cpp - main() function Checkpoint A For checkpoint A, you need to build a playlist (of songs) by readings data members of several songs from a file and printing them. Implement the following methods: PlayList(); //Default constructor PlayList(string filename); //Parameterized constructor that reads data members of song from a file and builds the PlayList ~PlayList(); //Deletes all nodes of the linked list bool InsertNodeLast(Node *myNewNode); //Inserts myNewNode at the end of the linked list bool InsertNodeFirst(Node *myNewNode); //Inserts myNewNode at the start of the linked list bool DeleteFirst(); //Deletes the first node of the linked list int Size() const { return size; } friend ostream& operator<< (ostream& out, const PlayList& LL); //Prints the linked list PlayList& operator=(const PlayList& other); //Overload the assignment operator such that the current PlayList is reverse of the other PlayLis Notes: InsertNodeLast and InsertNodeFirst are very similar to InsertFirst and InsertLast from Lab 08 except that these functions get a Node (to be inserted) as a parameter. DeleteFirst should be identical to that of Lab 08 The parameterized constructor needs to read data from file (for each song), create a new node, and call InsertNodeLast to insert the node in the list. The destructor deletes all nodes by repeatedly calling DeleteFirst (exactly same as lab 08) The implementation of << operator can be inferred from the desired output (see below) The assignment operator is virtually the same as that in lab 08 except with two important changes Instead of inserting nodes from the other list sequentially, it needs to insert them in the opposite order (which method can be used for that?) It must create a new node (copying attributes from the node in the other list) before inserting it into the list Testing and output How the following output should look like: "Peg" by Steely Dan is 237 seconds long. "All For You" by Janet Jackson is 391 seconds long. "Black Eagle" by Janet Jackson is 197 seconds long. Reversing the play list "Black Eagle" by Janet Jackson is 197 seconds long. "All For You" by Janet Jackson is 391 seconds long. "Peg" by Steely Dan is 237 seconds long.
Provide full C++ code
Building a playlist (of songs) using a linked list and making some operations such as adding songs, removing songs, shuffling them, etc. (Some parts of this lab will closely follow lab 08 - it is imperative that you complete that lab before working on this project).
A Node representing a song has the following data members (similar to struct Node of lab 08, except it doesn't have one member for storing data):
- string uniqueID
- string songName
- string artistName
- int songLength
- Node* nextNodePtr
Your code must have the following three files:
- Playlist.h - Class declaration for a linked list of Nodes (very similar to lab 08 but with some changes to methods, as described below) with following private data members:
private:
Node* first;
Node* last;
int size;
- Playlist.cpp - Class definition
- main.cpp - main() function
Checkpoint A
For checkpoint A, you need to build a playlist (of songs) by readings data members of several songs from a file and printing them.
Implement the following methods:
PlayList(); //Default constructor
PlayList(string filename); //Parameterized constructor that reads data members of song from a file and builds the PlayList
~PlayList(); //Deletes all nodes of the linked list
bool InsertNodeLast(Node *myNewNode); //Inserts myNewNode at the end of the linked list
bool InsertNodeFirst(Node *myNewNode); //Inserts myNewNode at the start of the linked list
bool DeleteFirst(); //Deletes the first node of the linked list
int Size() const { return size; }
friend ostream& operator<< (ostream& out, const PlayList& LL); //Prints the linked list
PlayList& operator=(const PlayList& other); //Overload the assignment operator such that the current PlayList is reverse of the other PlayLis
Notes:
- InsertNodeLast and InsertNodeFirst are very similar to InsertFirst and InsertLast from Lab 08 except that these functions get a Node (to be inserted) as a parameter.
- DeleteFirst should be identical to that of Lab 08
- The parameterized constructor needs to read data from file (for each song), create a new node, and call InsertNodeLast to insert the node in the list.
- The destructor deletes all nodes by repeatedly calling DeleteFirst (exactly same as lab 08)
- The implementation of << operator can be inferred from the desired output (see below)
- The assignment operator is virtually the same as that in lab 08 except with two important changes
- Instead of inserting nodes from the other list sequentially, it needs to insert them in the opposite order (which method can be used for that?)
- It must create a new node (copying attributes from the node in the other list) before inserting it into the list
Testing and output
How the following output should look like:
"Peg" by Steely Dan is 237 seconds long.
"All For You" by Janet Jackson is 391 seconds long.
"Black Eagle" by Janet Jackson is 197 seconds long.
Reversing the play list
"Black Eagle" by Janet Jackson is 197 seconds long.
"All For You" by Janet Jackson is 391 seconds long.
"Peg" by Steely Dan is 237 seconds long.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images