main.cpp (lab 9) | C++

October 30th, 2020 05:29:03 PM

					
#include <iostream> #include "PlaylistNode.h" using namespace std; void PrintMenu(string title); int main() { string plTitle; cout << "Enter playlist's title:" << endl; getline(cin, plTitle); PrintMenu(plTitle); return 0; } void PrintMenu(string title) { Playlist list; string id; string sname; string aname; int length; int oldPos; int newPos; char choice; while(true) { cout << endl << title << " PLAYLIST MENU" << endl; cout << "a - Add song" << endl; cout << "d - Remove song" << endl; cout << "c - Change position of song" << endl; cout << "s - Output songs by specific artist" << endl; cout << "t - Output total time of playlist (in seconds)" << endl; cout << "o - Output full playlist" << endl; cout << "q - Quit" << endl << endl; cout << "Choose an option:" << endl; cin >> choice; cin.ignore(); if (choice == 'q') { exit(1); } else if (choice == 'a') { cout << "\nADD SONG" << endl; cout << "Enter song's unique ID: "; cin >> id; cin.ignore(); cout << "Enter song's name: "; getline(cin,sname); cout << "Enter artist's name: "; getline(cin,aname); cout << "Enter song's length (in seconds): "; cin >> length; list.AddSong(id, sname, aname, length); } else if (choice == 'd') { cout << "\nREMOVE SONG" << endl; cout << "Enter song's unique ID: "; cin >> id; list.RemoveSong(id); } else if (choice == 'c') { cout << "\nCHANGE POSITION OF SONG" << endl; cout << "Enter song's current position: "; cin >> oldPos; cout << "Enter new position for song: "; cin >> newPos; list.ChangePosition(oldPos, newPos); } else if (choice == 's') { cout << "\nOUTPUT SONGS BY SPECIFIC ARTIST" << endl; cout << "Enter artist's name: "; getline(cin, aname); list.SongsByArtist(aname); } else if (choice == 't') { cout << "\nOUTPUT TOTAL TIME OF PLAYLIST (IN SECONDS)" << endl; cout << "Total time: " << list.TotalTime() << " seconds" << endl; } else if (choice == 'o') { cout << endl << title << " - OUTPUT FULL PLAYLIST" << endl; list.PrintList(); } else { cout << "Invalid menu choice! Please try again." << endl; } } }

Featured Posts