Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cstdlib>
- #include <ctime>
- #include <string>
- using namespace std;
- void AddGames(vector<string> &games);
- void PrintGames(vector<string> &games);
- void replaceGame(vector<string> &games);
- int main()
- {
- vector<string> games;
- bool end = false;
- int choice = 0;
- while (end != true)
- {
- cout << "1) Add game, 2) print games, 3) replace game 4)exit" << endl;
- cin >> choice;
- if (choice == 1)
- {
- AddGames(games);
- choice = 0;
- }
- if (choice == 2)
- {
- PrintGames(games);
- choice = 0;
- }
- if (choice == 3)
- {
- replaceGame(games);
- choice = 0;
- }
- if (choice == 4)
- {
- return 0;
- }
- }
- return 0;
- }
- void AddGames(vector<string> &games)
- {
- cout << "Enter name of game or 1) to exit OR EXIT TO GO BACK:" << endl;
- string tempGame = "";
- while (tempGame != "Exit")
- {
- getline(cin, tempGame);
- if (tempGame == "Exit")
- {
- break;
- }
- games.push_back(tempGame);
- tempGame = "";
- }
- }
- void PrintGames(vector<string> &games)
- {
- vector<string>::const_iterator iter;
- for (iter = games.begin(); iter != games.end(); ++iter)
- {
- cout << *iter << endl;
- }
- }
- void replaceGame(vector<string> &games)
- {
- cout << "Chose game to replace:" << endl;
- vector<string>::iterator myIterator;
- string tempFind = "";
- cin.ignore();
- getline(cin, tempFind);
- cout << "New game name:" << endl;
- string NewGame ="";
- cin>>NewGame;
- //vector<string>::const_iterator iter;
- std::replace(games.begin(), games.end(), tempFind,NewGame);
- tempFind = "";
- NewGame = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement