Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int menu()
- {
- int input; //users input
- system("CLS");
- cout << "Choose an option: \n";
- cout << "1. Display Games\n";
- cout << "2. Add Game\n";
- cout << "3. Count How Many Games You Have\n";
- cout << "4. Quit\n";
- cin >> input; //accepts input from user
- return input;
- }
- int main()
- {
- vector<string> gaming = { "guitar hero", "guitar hero 2", "guitar hero 3" }; //current games inside string
- bool flag = true;
- int game;
- string gamingGame;
- char quit;
- do
- {
- game = menu();
- switch (game)
- {
- case 1: //displays games
- system("CLS");
- for (unsigned int i = 0; i < gaming.size(); i++)
- {
- cout << gaming[i] << endl;
- }
- system("PAUSE");
- break;
- case 2: //adds games
- system("CLS");
- cin.ignore();
- cout << "Please enter the gaming name you want to add:\n";
- getline(cin,gamingGame); //gets input with spaces
- gaming.push_back(gamingGame); //adds game to the end of string
- break;
- case 3:
- system("CLS"); //counts how many games are in string
- cout << "You Have " << gaming.size() << " games to game\n";
- system("PAUSE");
- break;
- case 4: //quits
- flag = false;
- break;
- default: //if invalid entry
- cout << "invalid entry...try again.\n\n";
- system("PAUSE");
- break;
- }
- } while (flag);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement