Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a header file for a Playlist class. Please implement the following functions: 1. Playlist *Playlist::insert_at_cursor(const Song_Entry& s) // insert a node template 2.

I have a header file for a Playlist class. Please implement the following functions:

1. Playlist *Playlist::insert_at_cursor(const Song_Entry& s) // insert a node template

2. Playlist *Playlist::push_back(const Song_Entry& s) // insert a new node at the end

3. Playlist *Playlist::push_front(const Song_Entry& s) // insert a new node at the beginning

4. Playlist::Song_Entry& get_current_song() const // get Song_Entry object at current node

Please help as soon as possible. Thanks!

//Playlist.h

#ifndef Playlist_h #define Playlist_h #include #include #include using namespace std; class Playlist { public: // Inner public class --------------------------------------------------- // The client can refer to it by using the qualified name Playlist::Song_Entry class Song_Entry { // TODO - your code here private: int _id; string _name; public: Song_Entry(int id = 0, string name = "Unnamed") : _id(id), _name(name) {} int get_id() const { return _id; } string get_name() const { return _name; } bool set_id(int id); bool set_name(string name); bool operator==(const Song_Entry& that) { return this->_id == that._id && this->_name == that._name; } bool operator!=(const Song_Entry& that) { return !(*this == that); } friend std::ostream& operator<<(ostream& os, const Song_Entry& s) { return os << "{ id: "<< s.get_id() << ", name: " << s.get_name() << " }"; } friend class Tests; // Don't remove this line }; private: // This is going to be our inner private class. The client doesn't need to // know. class Node { // TODO - your code here private: Song_Entry _song; Node *_next; public: Node(const Song_Entry& song = Song_Entry()) : _song(song), _next(NULL) {} ~Node(); // Do not do recursive free Song_Entry& get_song() { return _song; } Node *get_next() { return _next; } Node *insert_next(Node *p); Node *remove_next(); friend std::ostream& operator<<(ostream& os, const Node* s) { // return os << "{ song: "<< s.get_song() << ", next: " << s.get_next() << " }"; } friend class Tests; // Don't remove this line }; private: Node *_head, *_tail, *_prev_to_current; size_t _size; public: Playlist(); ~Playlist(); size_t get_size() const { return _size; } Song_Entry& get_current_song() const; // The following return "this" on success, null on failure. See the spec // for why. Playlist *clear(); Playlist *rewind(); Playlist *push_back(const Song_Entry& s); Playlist *push_front(const Song_Entry& s); Playlist *insert_at_cursor(const Song_Entry& s); Playlist *remove_at_cursor(); Playlist *advance_cursor(); Playlist *circular_advance_cursor(); // The following return the target payload (or sentinel) reference on success Song_Entry& find_by_id(int id) const; Song_Entry& find_by_name(string songName) const; string to_string() const; friend class Tests; // Don't remove this line }; #endif /* String_List_h */

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

Students also viewed these Databases questions

Question

Which of the following has the same meaning as log_(1)320

Answered: 1 week ago

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago