Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #inlcude "List.h"
- #include <fstream>
- #include <iostream>
- #include <string>
- #include <cassert>
- using namespace std;
- void menu();
- int main () {
- List object; //create an object
- ifstream myIn; // read in data
- myIn.open("../topsongs.dat");
- assert(myIn);
- //sortedListClass( );
- ListItemType thing;
- while ( getline(myIn, thing.name ) ) {
- getline(myIn, thing.phoneNumber) ;
- object.SortedListInsert( thing);
- } //fill list with names
- int length = object.getLength(); // find the length of the list
- string MenuChoice;
- cout << "Please maximize your window to optimize your viewing of this program." <<endl<<endl;
- menu(); // display a menu
- cin >> MenuChoice;
- cout << endl;
- while (MenuChoice != "5") { // cycles through the different functions of the menu
- ListItemType userInput;
- if (MenuChoice == "1" ) {
- cout << "Remember: the name you enter is case-sensitive. " << endl;
- cout << "Please enter a name to search : " ;
- getline(cin.ignore(1024, '\n' ), userInput.name); //~~~~~~~~~~~~~~~~~~~ .name ok?
- object.Search( userInput) ;
- cout << endl;
- } // search
- else if (MenuChoice == "2") {
- cout << "Please enter a song to add : " ;
- getline(cin.ignore(1024, '\n' ), userInput.name);
- // ADD ~~~~~~~~~~~~~~~~~~~~~~
- length = object.getLength();
- object.DisplayList();
- // cout << "There are " << length << " users in the list. " << endl << endl; ~~~~~~~~~~~~~~~~~~~~~~~~~~
- } // add
- else if (MenuChoice == "3") {
- cout << "Remember: the item you enter is case-sensitive. " << endl;
- cout << "Please enter a song to delete : " ;
- getline(cin.ignore(1024, '\n' ), userInput.name);
- object.sortedListDelete(userInput);
- cout << endl;
- length = object.getLength();
- object.DisplayList();
- cout << "There are " << length << " users in the list. " << endl << endl;
- } // delete
- else if (MenuChoice == "4") {
- object.displayList() ;
- }
- else {
- cout << "The option you entered is not valid." << endl;
- }
- cout << "~The function for option " << MenuChoice << " has been executed.~" << endl << endl << endl;
- menu();
- cin >> MenuChoice;
- cout << endl;
- }
- cout << "You have successfully exited the program."<<endl<< "Thank you for using my program." << endl << endl;
- return 0;
- }
- void menu() {
- cout << "Please select an item from the menu below. " << endl;
- cout << "1: Look up an artist " << endl;
- cout << "2: Add a song " << endl;
- cout << "3: Delete a song " << endl;
- cout << "4: Print " << endl;
- cout << "5: Exit " << endl;
- cout << endl << "ENTER HERE: ";
- } // displays a menu of choices for the user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement