Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. #inlcude "List.h"
  2. #include <fstream>
  3. #include <iostream>
  4. #include <string>
  5. #include <cassert>
  6. using namespace std;
  7.  
  8.  
  9. void menu();
  10.  
  11.  
  12. int main () {
  13.  
  14. List object; //create an object
  15.  
  16. ifstream myIn; // read in data
  17.  
  18. myIn.open("../topsongs.dat");
  19. assert(myIn);
  20.  
  21. //sortedListClass( );
  22. ListItemType thing;
  23. while ( getline(myIn, thing.name ) ) {
  24. getline(myIn, thing.phoneNumber) ;
  25. object.SortedListInsert( thing);
  26. } //fill list with names
  27.  
  28. int length = object.getLength(); // find the length of the list
  29.  
  30.  
  31.  
  32.  
  33. string MenuChoice;
  34. cout << "Please maximize your window to optimize your viewing of this program." <<endl<<endl;
  35. menu(); // display a menu
  36. cin >> MenuChoice;
  37. cout << endl;
  38.  
  39. while (MenuChoice != "5") { // cycles through the different functions of the menu
  40.  
  41. ListItemType userInput;
  42.  
  43. if (MenuChoice == "1" ) {
  44. cout << "Remember: the name you enter is case-sensitive. " << endl;
  45. cout << "Please enter a name to search : " ;
  46. getline(cin.ignore(1024, '\n' ), userInput.name); //~~~~~~~~~~~~~~~~~~~ .name ok?
  47. object.Search( userInput) ;
  48. cout << endl;
  49. } // search
  50.  
  51. else if (MenuChoice == "2") {
  52. cout << "Please enter a song to add : " ;
  53. getline(cin.ignore(1024, '\n' ), userInput.name);
  54. // ADD ~~~~~~~~~~~~~~~~~~~~~~
  55. length = object.getLength();
  56. object.DisplayList();
  57. // cout << "There are " << length << " users in the list. " << endl << endl; ~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. } // add
  59.  
  60.  
  61. else if (MenuChoice == "3") {
  62. cout << "Remember: the item you enter is case-sensitive. " << endl;
  63. cout << "Please enter a song to delete : " ;
  64. getline(cin.ignore(1024, '\n' ), userInput.name);
  65. object.sortedListDelete(userInput);
  66. cout << endl;
  67. length = object.getLength();
  68. object.DisplayList();
  69. cout << "There are " << length << " users in the list. " << endl << endl;
  70. } // delete
  71.  
  72. else if (MenuChoice == "4") {
  73. object.displayList() ;
  74. }
  75.  
  76. else {
  77. cout << "The option you entered is not valid." << endl;
  78. }
  79.  
  80. cout << "~The function for option " << MenuChoice << " has been executed.~" << endl << endl << endl;
  81. menu();
  82. cin >> MenuChoice;
  83. cout << endl;
  84. }
  85. cout << "You have successfully exited the program."<<endl<< "Thank you for using my program." << endl << endl;
  86. return 0;
  87. }
  88.  
  89.  
  90.  
  91. void menu() {
  92. cout << "Please select an item from the menu below. " << endl;
  93. cout << "1: Look up an artist " << endl;
  94. cout << "2: Add a song " << endl;
  95. cout << "3: Delete a song " << endl;
  96. cout << "4: Print " << endl;
  97. cout << "5: Exit " << endl;
  98. cout << endl << "ENTER HERE: ";
  99. } // displays a menu of choices for the user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement