Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. enum typeGamesForMenu {
  8.     action = 1,
  9.     mmorpg,
  10.     adventure,
  11.     rpg,
  12.     sport,
  13.     simulator
  14. };
  15.  
  16. //{"ID", "Name", "Price"}
  17. struct gameData {
  18.     string id;
  19.     string name;
  20.     string number; //lepiej zeby bylo np intem, unsigned intem
  21. };
  22.  
  23. gameData gamesData[] = {
  24.     {"1", "Battlefield 1", "100"},
  25.     {"2", "WatchDogs 2", "120"},
  26.     {"3", "Grand Theft Auto 5", "80"},
  27.     {"4", "Black Desert Online", "50"},
  28.     {"5", "World of Warcraft", "50"},
  29.     {"6", "Eternal Magic", "50"},
  30.     {"7", "Ori and the Blind Forest", "170"},
  31.     {"8", "Resident Evil 3", "50"},
  32.     {"9", "Firewatch", "40"},
  33.     {"10", "The Wither 3", "50"},
  34.     {"11", "Cyberpunk 2077 (Preorder)", "199"},
  35.     {"12", "Disco Elysium", "150"},
  36.     {"13", "Fifa 2020", "160"},
  37.     {"14", "Rocket League", "50"},
  38.     {"15", "NBA 2k19", "40"},
  39.     {"16", "Car Mechanic Simulator", "50"},
  40.     {"17", "Farming Simulator 2020", "100"},
  41.     {"18", "Tank Mechanic Simulator", "30"},
  42. };
  43.  
  44. int typeGamesId[] = {
  45.     1, 1, 1,
  46.     2, 2, 2,
  47.     3, 3, 3,
  48.     4, 4, 4,
  49.     5, 5, 5,
  50.     6, 6, 6,
  51. };
  52.  
  53.  
  54. int userMoney = 1000,
  55.  
  56. choiceType,
  57. chooseGameId,
  58. yesOrNot;
  59.  
  60. void buyGameMenu(int gameId, string gameName, string gamePrice) {
  61.     cout << "=- Czy jesteś pewny czy chcesz zakupić " << gameName << "? -=" << endl;
  62.     cout << "=- Gra kosztuje " << gamePrice << " PLN -=" << endl;
  63.     cout << "=- Tak (Wpisz 1) -=" << endl;
  64.     cout << "=- Nie (Wpisz 2) -=" << endl;
  65.     cout << "Wybierz: ";
  66.     cin >> yesOrNot;
  67.    
  68.     switch(yesOrNot)
  69.     {
  70.         case 1:
  71.         {
  72.             cout << "Zakupiles " << gameName << " za " << gamePrice << " PLN." << endl;
  73.             cout << "Zapraszamy ponownie :)" << endl;
  74.            
  75.             int i_gamePrice = stoi(gamePrice);
  76.            
  77.             userMoney -= i_gamePrice;
  78.            
  79.             cout << "Twój stan konta wynosi: " << userMoney << endl;
  80.            
  81.             break;
  82.         }
  83.         case 2:
  84.         {
  85.             cout << "Zastanów się lepiej";
  86.             break;
  87.         }
  88.         default: {
  89.             cout << "Nie ma takiej opcji";
  90.         }
  91.     }
  92. }
  93.  
  94. int main()  {
  95.    
  96.     typeGamesForMenu id;
  97.    
  98.     cout << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" << endl;
  99.     cout << "=- Witaj w sklepie z grami -=" << endl;
  100.     cout << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" << endl;
  101.     cout << "=- Rodzaje gier: -=" << endl << endl;
  102.     cout << "- Gry Akcji (Wpisz 1)" << endl;
  103.     cout << "- Gry MMORPG (Wpisz 2)" << endl;
  104.     cout << "- Gry Przygodowe (Wpisz 3)" << endl;
  105.     cout << "- Gry RPG (Wpisz 4)" << endl;
  106.     cout << "- Gry Sportowe (Wpisz 5)" << endl;
  107.     cout << "- Gry Symulacyjne (Wpisz 6)" << endl << endl;
  108.     cout << "=- Twój stan konta: " << userMoney << " PLN -=" << endl << endl;
  109.    
  110.     cout << "Wybierz swój ulubiony gatunek: ";
  111.     cin >> choiceType;
  112.    
  113.     switch(choiceType)
  114.     {
  115.         case action:
  116.         {
  117.             cout << endl << "Dostępne gry (Gry Akcji):" << endl;
  118.             for(int i = 0; i < 3; i++)
  119.             {
  120.                 if(typeGamesId[i] == choiceType)
  121.                 {
  122.                     cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
  123.                 }
  124.             }
  125.             cout << endl << "Wybierz grę, którą chcesz kupić: ";
  126.             cin >> chooseGameId;
  127.            
  128.             chooseGameId -= 1;
  129.            
  130.             buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
  131.            
  132.             break;
  133.         }
  134.         case mmorpg:
  135.         {
  136.             cout << endl << "Dostępne gry (Gry MMORPG):" << endl;
  137.             for(int i = 3; i < 6; i++)
  138.             {
  139.                 if(typeGamesId[i] == choiceType)
  140.                 {
  141.                     cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
  142.                 }
  143.             }
  144.             cout << "Wybierz grę, którą chcesz kupić: ";
  145.             cin >> chooseGameId;
  146.            
  147.             chooseGameId -= 1;
  148.            
  149.             buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
  150.            
  151.             break;
  152.         }
  153.         case adventure:
  154.         {
  155.             cout << endl << "Dostępne gry (Gry Przygodowe):" << endl;
  156.             for(int i = 6; i < 9; i++)
  157.             {
  158.                 if(typeGamesId[i] == choiceType)
  159.                 {
  160.                     cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
  161.                 }
  162.             }
  163.             cout << "Wybierz grę, którą chcesz kupić: ";
  164.             cin >> chooseGameId;
  165.            
  166.             chooseGameId -= 1;
  167.            
  168.             buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
  169.            
  170.             break;
  171.         }
  172.         case rpg:
  173.         {
  174.             cout << endl << "Dostępne gry (Gry RPG):" << endl;
  175.             for(int i = 9; i < 12; i++)
  176.             {
  177.                 if(typeGamesId[i] == choiceType)
  178.                 {
  179.                     cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
  180.                 }
  181.             }
  182.             cout << "Wybierz grę, którą chcesz kupić: ";
  183.             cin >> chooseGameId;
  184.            
  185.             chooseGameId -= 1;
  186.            
  187.             buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
  188.            
  189.             break;
  190.         }
  191.         case sport:
  192.         {
  193.             cout << endl << "Dostępne gry (Gry Sportowe):" << endl;
  194.             for(int i = 12; i < 15; i++)
  195.             {
  196.                 if(typeGamesId[i] == choiceType)
  197.                 {
  198.                     cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
  199.                 }
  200.             }
  201.             cout << "Wybierz grę, którą chcesz kupić: ";
  202.             cin >> chooseGameId;
  203.            
  204.             chooseGameId -= 1;
  205.            
  206.             buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
  207.            
  208.             break;
  209.         }
  210.         case simulator:
  211.         {
  212.             cout << endl << "Dostępne gry (Gry Symulacyjne):" << endl;
  213.             for(int i = 15; i < 18; i++)
  214.             {
  215.                 if(typeGamesId[i] == choiceType)
  216.                 {
  217.                     cout << gamesData[i].id << ". " << gamesData[i].name << " - Cena: " << gamesData[i].number << " PLN (Wpisz " << i + 1 << ")" << endl;
  218.                 }
  219.             }
  220.             cout << "Wybierz grę, którą chcesz kupić: ";
  221.             cin >> chooseGameId;
  222.            
  223.             chooseGameId -= 1;
  224.            
  225.             buyGameMenu(chooseGameId, gamesData[chooseGameId].name, gamesData[chooseGameId].number);
  226.            
  227.             break;
  228.         }
  229.         default: {
  230.             cout << "Nie ma takiej opcji" << endl << endl;
  231.             main();
  232.            
  233.         }
  234.     }
  235.     return 0;
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement