Advertisement
Koalaazz

Untitled

Dec 14th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int menu()
  8. {
  9. int input; //users input
  10.  
  11. system("CLS");
  12. cout << "Choose an option: \n";
  13. cout << "1. Display Games\n";
  14. cout << "2. Add Game\n";
  15. cout << "3. Count How Many Games You Have\n";
  16. cout << "4. Quit\n";
  17. cin >> input; //accepts input from user
  18. return input;
  19. }
  20.  
  21. int main()
  22. {
  23. vector<string> gaming = { "guitar hero", "guitar hero 2", "guitar hero 3" }; //current games inside string
  24. bool flag = true;
  25. int game;
  26. string gamingGame;
  27. char quit;
  28.  
  29. do
  30. {
  31. game = menu();
  32.  
  33. switch (game)
  34. {
  35. case 1: //displays games
  36. system("CLS");
  37. for (unsigned int i = 0; i < gaming.size(); i++)
  38. {
  39. cout << gaming[i] << endl;
  40. }
  41. system("PAUSE");
  42. break;
  43.  
  44. case 2: //adds games
  45. system("CLS");
  46. cin.ignore();
  47. cout << "Please enter the gaming name you want to add:\n";
  48. getline(cin,gamingGame); //gets input with spaces
  49. gaming.push_back(gamingGame); //adds game to the end of string
  50. break;
  51.  
  52. case 3:
  53. system("CLS"); //counts how many games are in string
  54. cout << "You Have " << gaming.size() << " games to game\n";
  55. system("PAUSE");
  56. break;
  57.  
  58. case 4: //quits
  59. flag = false;
  60. break;
  61.  
  62. default: //if invalid entry
  63. cout << "invalid entry...try again.\n\n";
  64. system("PAUSE");
  65. break;
  66. }
  67. } while (flag);
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement