Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdio>
- using namespace std;
- enum typeGamesForMenu {
- action = 1,
- mmorpg,
- adventure,
- rpg,
- sport,
- simulator
- };
- //{"ID", "Name", "Price"}
- struct gameData {
- string id;
- string name;
- string number; //lepiej zeby bylo np intem, unsigned intem
- };
- gameData gamesData[] = {
- {"1", "Battlefield 1", "100"},
- {"2", "WatchDogs 2", "120"},
- {"3", "Grand Theft Auto 5", "80"},
- {"4", "Black Desert Online", "50"},
- {"5", "World of Warcraft", "50"},
- {"6", "Eternal Magic", "50"},
- {"7", "Ori and the Blind Forest", "170"},
- {"8", "Resident Evil 3", "50"},
- {"9", "Firewatch", "40"},
- {"10", "The Wither 3", "50"},
- {"11", "Cyberpunk 2077 (Preorder)", "199"},
- {"12", "Disco Elysium", "150"},
- {"13", "Fifa 2020", "160"},
- {"14", "Rocket League", "50"},
- {"15", "NBA 2k19", "40"},
- {"16", "Car Mechanic Simulator", "50"},
- {"17", "Farming Simulator 2020", "100"},
- {"18", "Tank Mechanic Simulator", "30"},
- };
- int typeGamesId[] = {
- 1, 1, 1,
- 2, 2, 2,
- 3, 3, 3,
- 4, 4, 4,
- 5, 5, 5,
- 6, 6, 6,
- };
- int userMoney = 1000,
- choiceType,
- chooseGameId,
- yesOrNot;
- void buyGameMenu(int gameId, string gameName, string gamePrice) {
- cout << "=- Czy jesteś pewny czy chcesz zakupić " << gameName << "? -=" << endl;
- cout << "=- Gra kosztuje " << gamePrice << " PLN -=" << endl;
- cout << "=- Tak (Wpisz 1) -=" << endl;
- cout << "=- Nie (Wpisz 2) -=" << endl;
- cout << "Wybierz: ";
- cin >> yesOrNot;
- switch(yesOrNot)
- {
- case 1:
- {
- cout << "Zakupiles " << gameName << " za " << gamePrice << " PLN." << endl;
- cout << "Zapraszamy ponownie :)" << endl;
- int i_gamePrice = stoi(gamePrice);
- userMoney -= i_gamePrice;
- cout << "Twój stan konta wynosi: " << userMoney << endl;
- break;
- }
- case 2:
- {
- cout << "Zastanów się lepiej";
- break;
- }
- default: {
- cout << "Nie ma takiej opcji";
- }
- }
- }
- int main() {
- typeGamesForMenu id;
- cout << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" << endl;
- cout << "=- Witaj w sklepie z grami -=" << endl;
- cout << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" << endl;
- cout << "=- Rodzaje gier: -=" << endl << endl;
- cout << "- Gry Akcji (Wpisz 1)" << endl;
- cout << "- Gry MMORPG (Wpisz 2)" << endl;
- cout << "- Gry Przygodowe (Wpisz 3)" << endl;
- cout << "- Gry RPG (Wpisz 4)" << endl;
- cout << "- Gry Sportowe (Wpisz 5)" << endl;
- cout << "- Gry Symulacyjne (Wpisz 6)" << endl << endl;
- cout << "=- Twój stan konta: " << userMoney << " PLN -=" << endl << endl;
- cout << "Wybierz swój ulubiony gatunek: ";
- cin >> choiceType;
- switch(choiceType)
- {
- case action:
- {
- cout << endl << "Dostępne gry (Gry Akcji):" << endl;
- for(int i = 0; i < 3; i++)
- {
- if(typeGamesId[i] == choiceType)
- {
- cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
- }
- }
- cout << endl << "Wybierz grę, którą chcesz kupić: ";
- cin >> chooseGameId;
- chooseGameId -= 1;
- buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
- break;
- }
- case mmorpg:
- {
- cout << endl << "Dostępne gry (Gry MMORPG):" << endl;
- for(int i = 3; i < 6; i++)
- {
- if(typeGamesId[i] == choiceType)
- {
- cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
- }
- }
- cout << "Wybierz grę, którą chcesz kupić: ";
- cin >> chooseGameId;
- chooseGameId -= 1;
- buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
- break;
- }
- case adventure:
- {
- cout << endl << "Dostępne gry (Gry Przygodowe):" << endl;
- for(int i = 6; i < 9; i++)
- {
- if(typeGamesId[i] == choiceType)
- {
- cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
- }
- }
- cout << "Wybierz grę, którą chcesz kupić: ";
- cin >> chooseGameId;
- chooseGameId -= 1;
- buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
- break;
- }
- case rpg:
- {
- cout << endl << "Dostępne gry (Gry RPG):" << endl;
- for(int i = 9; i < 12; i++)
- {
- if(typeGamesId[i] == choiceType)
- {
- cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
- }
- }
- cout << "Wybierz grę, którą chcesz kupić: ";
- cin >> chooseGameId;
- chooseGameId -= 1;
- buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
- break;
- }
- case sport:
- {
- cout << endl << "Dostępne gry (Gry Sportowe):" << endl;
- for(int i = 12; i < 15; i++)
- {
- if(typeGamesId[i] == choiceType)
- {
- cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
- }
- }
- cout << "Wybierz grę, którą chcesz kupić: ";
- cin >> chooseGameId;
- chooseGameId -= 1;
- buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
- break;
- }
- case simulator:
- {
- cout << endl << "Dostępne gry (Gry Symulacyjne):" << endl;
- for(int i = 15; i < 18; i++)
- {
- if(typeGamesId[i] == choiceType)
- {
- cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
- }
- }
- cout << "Wybierz grę, którą chcesz kupić: ";
- cin >> chooseGameId;
- chooseGameId -= 1;
- buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
- break;
- }
- default: {
- cout << "Nie ma takiej opcji" << endl << endl;
- main();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement