I need help with making hierarchy chart showing the logical components of this program here is the code below: #include #include #define MAX 100 using namespace std; // Song class class Song { private: string title; string artist; string genre; float length; public: Song() {} Song(string t, string a, string g, float l) { title = t; artist = a; genre = g; length = l; } // displays the song void display() { cout << ” Title: t” << title << “n”; cout << ” Artist:t” << artist << “n”; cout << ” Genre: t” << genre << “n”; cout << ” Length:t” << length << “nn”; } float getLength() { return length; } }; // Playlist class class Playlist { private: string name; int totalSongs; Song songs[MAX]; public: Playlist() {} Playlist(string n) { name = n; totalSongs = 0; } // adds song to the playlist void addSong(Song song) { if (totalSongs < MAX) { songs[totalSongs] = song; totalSongs++; cout << “Song added successfully” << endl; } else { cout << “Playlist Full!” << endl; } } // displays the playlist void display() { cout << “Name of the playlist: ” << name << endl; if (totalSongs == 0) cout << “Playlist is empty!” << endl; else { for (int i = 0; i < totalSongs; i++) { cout << i + 1 << “.————————————–n”; songs[i].display(); } cout << “The playlist of name ” << name << ” has a total length of ” << getTotalLength() << endl; } } // returns total length float getTotalLength() { float length = 0; for (int i = 0; i < totalSongs; i++) { length += songs[i].getLength(); } return length; } }; // reads the song data and returns the song object Song getSong() { string title, artist, genre; float length; fflush(stdin); cout << “Insert the title of the song: “; getline(cin, title); cout << “Insert the artist name of the song: “; getline(cin, artist); cout << “Insert the genre of the song: “; getline(cin, genre); cout << “Insert the length of the song: “; cin >> length; // create song object and return it Song song(title, artist, genre, length); return song; } // displays the menu and returns the menu choice int menu() { int menuChoice; cout << “n1. Create New Playlist” << endl; cout << “2. Dispay all Playlists” << endl; cout << “3. Exit” << endl; cout << “Enter your choice [1-3]: “; cin >> menuChoice; return menuChoice; } int main() { //Declare variables /* Name, title, artist, and genre are of type string. length is type float. */ string name; int menuChoice; int count = 0; char choice; Playlist playList[MAX]; // print header cout << “############################################################n”; cout << ” DJ Playlist Managern”; cout << “############################################################n”; // continue displaying menu options, until user quits while (true) { // get menu choice menuChoice = menu(); // Add playlist if (menuChoice == 1) { fflush(stdin); cout << “Insert a name for this playlist: “; getline(cin, name); Playlist newPlayList(name); // keep asking for songs to add into the playlist while (true) { cout << “Do you want to add songs? (y/n): “; cin >> choice; if (choice == ‘y’ || choice == ‘Y’) { newPlayList.addSong(getSong()); } else break; } playList[count] = newPlayList; count++; } // display all playlist else if (menuChoice == 2) { if (count == 0) { cout << “No Playlist Found!” << endl; } else { for (int i = 0; i < count; i++) { playList[i].display(); } } } else if (menuChoice == 3) { break; } else { cout << “Invalid Choice! Try Again!” << endl; } } return 0; }
Expert Answer
There are three logical components in the program:
1.Song
2.Playlist
3.Playlist Manager
So for the hierarchy, we have the following
Playlist Manager
Create Playlist Display Playlist
Take Inputs ProcessInput AddSongData Take input ProcessInput DisplaySongs