Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone answer these questions about the code? (only in words no code required unless you need to copy mine and put a section to

Can someone answer these questions about the code? (only in words no code required unless you need to copy mine and put a section to answer a question.)

********DON'T GET THROWN OFF BY HOW MUCH STUFF THERE IS I ONLY NEED ANSWERS TO THE QUESTIONS IN BOLD.*******

1)What functions does the ADT have

2)How each function will report success/failure back to the calling routine

3)How each function will shield the client program from the details of the data structure

4)What data structures you will be using and how each of the special cases.

5)Which function/functions are recursive?

6) What are the design considerations, what are the main design considerations, why they are the main design considerations, and how this program solved the problems?

**********************I have already written my code and this is what it is supposed to do.************************

"Part I: The Song ADT

The information about a song should include:

Artist name (e.g., Eminem)

Title(e.g., Lose Yourself)

Length (e.g., 5.23)

Number of likes (e.g., 654,000)

Part II: The SongList ADT

The data members for SongList should be a head pointer to a linear linked list of Song objects and the number of songs in the list. The songs should be organized by popularities with the most popular song as the first node in the list.

This ADT must have public member functions to perform the following:

1.Constructor - Construct an object and initialize the data members

2.Destructor - Release all dynamic memory and reset data members to their zero equivalent value

3.Add a new song

4.Edit the number of likes for a song

5.Display all songs in the list

6.Display all songs for an artist (in order of popularity)

7.Remove all songs with fewer than M likes, where M is sent in as an argument

Part III: The driver or the test program

The test program needs to first load the test data set from external file at the beginning of the program.

The menu-based user interface should allow user to use/test ALL the functionalities of the program. Try to make the user interface easier to use."

************************My songs.txt is below (the file I will read from).*********************************

BTS, DYNAMITE, 3.43, 41000000

NF, CLOUDS, 1.14, 869000

HARRY, FALLING, 3.27, 30000000

RACHEL, FIGHT SONG, 3.23, 166000

RUTH, LOST BOY, 4.33, 65000

JAMES, SAY YOU WONT LET GO, 3.27 213000

HARRY, SIGN OF THE TIMES, 5.41, 63000000

IDENA, LET IT GO, 3.21, 21000000

BTS, BLACK SWAN, 3.43, 23000000

PASSENGER, LET HER GO, 4.20, 97000

KATIE, DAISIES, 2.53, 12000

BEBE, SACRIFICES, 2.40, 300000

ANDY, DONT GIVE UP ON ME, 3.16, 5600000

JUSTIN, BIGGER THAN, 3.28, 21000

SAM, IM READY, 3.20, 30500

ALEC, OH MY GOD, 3.07, 1000000

ANDY, GOOD EXAMPLE, 2.29, 15000

GREYSON, GOOD AS GOLD, 3.25, 78000

BRYNN, TELL ME IM PRETTY, 3.08, 29000

GRYFFIN, CRY, 3.38, 3000000

KHALID, FREE SPIRIT, 3.02, 55000

KYGO, LIKE IT IS, 3.03, 890000

CHAINSMOKERS, THIS FEELING, 3.17, 760000

KASKADE, WITH YOU, 3.00, 2000

LAUV, LIKE ME BETTER, 3.17, 5000000

AVA, SALT, 3.00, 56900

LEWIS, BEFORE YOU GO, 3.50, 89000

LAUV, NEVER NOT, 4.02, 76000

JEREMY, ALWAYS ILL CARE, 2.40, 68000

JAMES, IMPOSSIBLE, 4.07, 49000

GMILLER, NO TEARS LEFT TO CRY, 3.10, 770000

******MY CODE*******

 //playlist.h #ifndef _PLAYLIST_H_ #define _PLAYLIST_H_ #include  #include "song.h" using namespace std; class Playlist { public: Playlist(); ~Playlist(); void AddSong(const Song& s); void DeleteSong(const Song& s); void Show(); private: Song *playList; int size_of_playlist; int numberOfSongs; }; #endif  // playlist.cpp #include  #include  #include  #include  #include "playlist.h" using namespace std; Playlist::Playlist() { size_of_playlist = 2; numberOfSongs = 0; playList = new Song[size_of_playlist]; } Playlist::~Playlist() { delete [] playList; } void Playlist::AddSong(const Song& s) { if (numberOfSongs == size_of_playlist) { Song* arr = new Song[size_of_playlist+1]; arr[size_of_playlist] = s; for(int i = 0; i < size_of_playlist; i++) { arr[i] = playList[i]; } playList = arr; delete[] arr; arr = NULL; } else { numberOfSongs++; playList[numberOfSongs - 1] = s; } } void Playlist::DeleteSong(const Song& s) { // First search specified song int index = 0; /*for (index = 0; index < numberOfSongs; index++) { if (playList[index] == s) { break; } }*/ // Maybe not found if (index == numberOfSongs) { return; } // Remove song fron array while (index < (numberOfSongs-1)) { playList[index] = playList[index+1]; index++; } // We got one less song numberOfSongs--; } void Playlist::Show() { Song s; if (numberOfSongs == size_of_playlist) { Song* arr = new Song[size_of_playlist+1]; arr[size_of_playlist] = s; for(int i = 0; i < size_of_playlist; i++) { arr[i] = playList[i]; cout << arr[i].GetTitle(); } } } // song.h #include  using namespace std; #ifndef _SONG_H #define _SONG_H enum Style {POP, ROCK, ALTERNATIVE, COUNTRY, HIPHOP, PARODY}; class Song { // operator overload -- described at bottom friend ostream& operator<<(ostream& os, const Song& s); public: Song(); // default constructor, sets up blank song object of <"", "", Pop, 0> void Set(const char* t, const char* a, Style st, int sz); const char* GetTitle() const; // returns the title stored in the object const char* GetArtist() const; // returns the artist int GetSize() const; // returns the file size in kilobytes Style GetCategory() const; // returns the song category private: char title[36]; // may assume title is 35 characters or less char artist[21]; // may assume artist name is 20 characters or less Style category; // style of the given song int size; // file size, stored in kilobytes }; /* Title Artist Style Size (MB) Examples: Pictures of You The Cure Alt 4.4 Bohemian Rhapsody Queen Rock 5.7 What Does the Fox Say Ylvis Par 12.6 */ #endif // song.cpp #include  #include  #include  #include  #include "song.h" using namespace std; Song::Song() { strcpy(title, ""); strcpy(artist, ""); category = POP; size = 0; } void Song::Set(const char *t, const char *a, Style st, int sz) { t = title; a = artist; st = category; sz = size; } const char* Song::GetTitle() const { return title; } const char* Song::GetArtist() const { return artist; } int Song::GetSize()const { return size; } Style Song::GetCategory() const { return category; } ostream& operator<<(ostream& os, const Song& s) { os << s.title << setw(15) << s.artist << setw(15) << s.category << setw(10) << s.size << endl; return os; } // main.cpp #include  #include  #include  #include "song.h" #include "playlist.h" using namespace std; int main() { int ss; char ti[36], ar[25]; int sinput; Song s; Style g; Playlist f; char search[36]; char input; do { cout << "------MENU------ " << endl; cout << "A: Add a song to the playlist" << endl; cout << "F: Find a song on the playlist" << endl; cout << "D: Delete a song from the playlist" << endl; cout << "S: Show the entire playlist" << endl; cout << "C: Category summary" << endl; cout << "Z: Show playlist size" << endl; cout << "M: Show this menu" << endl; cout << "X: Exit the program" << endl; cout << "Enter your input: "; cin >> input; if ( input == 'a' || input == 'A') { cin.ignore(); cout << "Please enter the title: "; cin.get(ti, 36, ' '); cin.ignore(); cout << " Please enter the artist: "; cin.get(ar, 25, ' '); cout << "Please enter a category: "; cin >> sinput; g = static_cast