Advertisement
pjobro

casino nedovrseno b

Mar 23rd, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.91 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <ctime>
  6. using namespace std;
  7.  
  8. // deklaracija funkcija
  9. void welcome(string &name, int &money);
  10. void user_stats(string name, int money, int chipsss);
  11. void menu();
  12. void uplata(int &money, int &chipsss);
  13. void isplata(int &money, int &chipsss);
  14. void igre_menu();
  15. void jednoruki_jack(string name, int &money, int &chipsss);
  16. void bacanje_kockica(string name, int &money, int &chipsss);
  17.  
  18. int main()
  19. {
  20.     srand(time(NULL));
  21.     string ime;
  22.     int novac, chip = 20, odabir;
  23.    
  24.     welcome(ime, novac); // unos imena i novca
  25.    
  26.     do {
  27.         system("cls");
  28.  
  29.         user_stats(ime, novac, chip); // ispis imena, novca, chipova
  30.         menu(); // glavni menu
  31.  
  32.         cout << "\tVas odabir: ";
  33.         cin >> odabir;
  34.          
  35.  
  36.         switch (odabir)
  37.         {
  38.         case 1:
  39.             uplata(novac, chip);
  40.             break;
  41.         case 2:
  42.             isplata(novac, chip);
  43.             break;
  44.  
  45.         case 3:
  46.             int odabir_igre;
  47.             system("cls");
  48.             user_stats(ime, novac, chip);
  49.             igre_menu();
  50.  
  51.             do {
  52.                 cin >> odabir_igre;
  53.                 switch (odabir_igre) {
  54.                 case 1:
  55.                     system("cls");
  56.                     user_stats(ime, novac, chip);
  57.  
  58.                     jednoruki_jack(ime, novac, chip);
  59.  
  60.                     cout << "\n\t1 - Jednoruki Jack (slot machine)" << endl;
  61.                     cout << "\t2 - Bacanje kockica" << endl;
  62.                     cout << "\t3 - Double or nothing" << endl;
  63.                     cout << "\t0 - Glavni meni" << endl;
  64.                     break;
  65.                 case 2:
  66.                     system("cls");
  67.                     user_stats(ime, novac, chip);
  68.  
  69.                     bacanje_kockica(ime, novac, chip);
  70.                      
  71.                     cout << "\n\t1 - Jednoruki Jack (slot machine)" << endl;
  72.                     cout << "\t2 - Bacanje kockica" << endl;
  73.                     cout << "\t3 - Double or nothing" << endl;
  74.                     cout << "\t0 - Glavni meni" << endl;
  75.                 case 3:
  76.                 case 0:
  77.                     break;
  78.                 default:
  79.                     cout << "\n\tOdaberite igre 1 - 3. Za izlaz koristite 0. Vas odabir: ";
  80.                     break;
  81.                 }
  82.             } while (odabir_igre != 0);
  83.             break;
  84.  
  85.         case 0:
  86.             break;
  87.         default:
  88.             system("cls");
  89.             user_stats(ime, novac, chip);
  90.             igre_menu();
  91.             cout << "Krivi unos! Odaberite brojeve 1 - 4 ili 0 za izlaz\n";
  92.             break;
  93.         }
  94.  
  95.     } while (odabir != 0);
  96.  
  97.  
  98.     system("pause");
  99.     return 0;
  100. }
  101.  
  102.  
  103.  
  104.  
  105.  
  106. // --- FUNKCIJE ---
  107.  
  108. void welcome(string &name, int &money) {
  109.     cout << "\n\tDobrodosli u C++ CASINO\n" << endl;
  110.     cout << "\tUnesite svoje ime: ";
  111.     cin >> name;
  112.     cout << "\tKoliko novca imate: ";
  113.     cin >> money;
  114. }
  115.  
  116. void user_stats(string name, int money, int chipsss) {
  117.     cout << "\n\tUser: " << name << "\tMoney: " << money << "\tChip: " << chipsss << endl;
  118. }
  119.  
  120. void menu() {
  121.     cout << "\n\t1 - Uplata novca - zamjena za chip-ove - 1 chip = 5 kn" << endl;
  122.     cout << "\t2 - Isplata novca" << endl;
  123.     cout << "\t3 - Odabir igre" << endl;
  124.     cout << "\t4 - High score" << endl;
  125.     cout << "\t0 - Izlaz iz programa" << endl;
  126. }
  127.  
  128. void uplata(int &money, int &chipsss) {
  129.     int potrositi;
  130.     cout << "\n\tKoliko novca zelite zamjeniti za chipove?: ";
  131.     cin >> potrositi;
  132.  
  133.     if (potrositi <= money)
  134.     {
  135.         chipsss += (potrositi - (potrositi % 5)) / 5;
  136.         money -= potrositi - (potrositi % 5);
  137.         cout << "\tMoney spent: " << potrositi - (potrositi % 5) << "\tNew chips: " << (potrositi - (potrositi % 5)) / 5 << "\n";
  138.  
  139.     }
  140.     else if (potrositi > money)
  141.     {
  142.         chipsss += (money - (money % 5)) / 5;
  143.         cout << "\tMoney spent: " << money - (money % 5) << "\tNew chips: " << (money - (money % 5)) / 5 << "\n";
  144.         money %= 5;
  145.        
  146.     }
  147.     system("pause");
  148.  
  149. }
  150.  
  151. void isplata(int &money, int &chipsss) {
  152.     int koliko_chipova;
  153.     string siguran;
  154.     cout << "\n\tMozete dobiti: " << chipsss * 5 << " novaca za " << chipsss << " chipova" << endl;
  155.     cout << "\n\tKoliko chipova zelite unovciti? ";
  156.     cin >> koliko_chipova;
  157.  
  158.  
  159.  
  160.     if (koliko_chipova > chipsss) {
  161.         cout << "\tNemate toliko chipova\n";
  162.     }
  163.     else
  164.     {
  165.         cout << "\n\tJeste sigurni? DA - nastavak, NE - prekid: ";
  166.         cin >> siguran;
  167.         if (siguran == "DA" || siguran == "da") {
  168.             chipsss -= koliko_chipova;
  169.             money += koliko_chipova * 5;
  170.             cout << "\n\tDobili ste " << koliko_chipova * 5 << " novca za " << koliko_chipova << " chipova\n\n";
  171.         }
  172.         else if (siguran == "NE" || siguran == "ne") {
  173.             cout << "\n\tNiste razmjenili chipove za novac.\n";
  174.         }
  175.     }
  176.     system("pause");
  177. }
  178.  
  179. void igre_menu() {
  180.     cout << "\n\t1 - Jednoruki Jack (slot machine)" << endl;
  181.     cout << "\t2 - Bacanje kockica" << endl;
  182.     cout << "\t3 - Double or nothing" << endl;
  183.     cout << "\t0 - Glavni meni" << endl;
  184.     cout << "\tVas odabir: ";
  185. }
  186.  
  187. void jednoruki_jack(string name, int &money, int &chipsss) {
  188.    
  189.     int rollaj;
  190.     int slot1;
  191.     int slot2;
  192.     int slot3;
  193.  
  194.     cout << "\n\tJednoruki Jack! 1 game = 1 money" << endl;
  195.     cout << "\t1 - Roll!" << endl;
  196.     cout << "\t0 - Exit!" << endl;
  197.     cout << "\n\tRoll?: ";
  198.  
  199.     do {
  200.         cin >> rollaj;
  201.         system("cls");
  202.  
  203.         switch (rollaj) {
  204.         case 1:
  205.             if (chipsss > 0) {
  206.                 slot1 = rand() % 4 + 1;
  207.                 slot2 = rand() % 4 + 1;
  208.                 slot3 = rand() % 4 + 1;
  209.  
  210.  
  211.  
  212.                 if (slot1 == slot2 && slot2 == slot3) {
  213.                     chipsss += 15;
  214.                     user_stats(name, money, chipsss);
  215.  
  216.                     cout << "\n\tJednoruki Jack! 1 game = 1 money" << endl;
  217.                     cout << "\t1 - Roll!" << endl;
  218.                     cout << "\t2 - Exit!" << endl;
  219.  
  220.                     cout << "\n\t| " <<  slot1 << " | " << slot2 << " | " << slot3 << " |";
  221.                     cout << "\tYou won 16 moneyz" << endl;
  222.                 }
  223.                 else {
  224.                     chipsss--;
  225.                     user_stats(name, money, chipsss);
  226.  
  227.                     cout << "\n\tJednoruki Jack! 1 game = 1 money" << endl;
  228.                     cout << "\t1 - Roll!" << endl;
  229.                     cout << "\t2 - Exit!" << endl;
  230.  
  231.                     cout << "\n\t| " << slot1 << " | " << slot2 << " | " << slot3 << " |\n";
  232.                 }
  233.  
  234.                 cout << "\n\tRoll? ";
  235.             }
  236.             else {
  237.                 cout << "\n\tYou dont have money. Return with money.\n";
  238.                 cout << "\n\tPress 0 to exit.\n";
  239.             }
  240.             break;
  241.         case 0:
  242.             break;
  243.         default:
  244.             cout << "\n\tWrong entry. 1 - Roll, 0 - Exit\n";
  245.             break;
  246.         }
  247.     } while (rollaj != 0);
  248. }
  249.  
  250. void bacanje_kockica(string name, int &money, int &chipsss) {
  251.  
  252.     int baci_kockicu;
  253.     int korisnik_kocka_score;
  254.     int racunalo_kocka_score;
  255.     int ulog_kockice;
  256.     cout << "\n\tBacanje kockica!\n\n";
  257.     cout << "\tVas ulog: ";
  258.     cin >> ulog_kockice;
  259.  
  260.     if (ulog_kockice <= chipsss) {
  261.  
  262.         cout << "\n\tBacite s tipkom 1: ";
  263.         cin >> baci_kockicu;
  264.         int kockica1 = rand() % 6 + 1;
  265.         cout << "\t" << name << " - kockica: " << kockica1;
  266.         korisnik_kocka_score = kockica1;
  267.  
  268.         cout << "\n\tRacunalo ";
  269.         int kockica2 = rand() % 6 + 1;
  270.         cout << "kockica: " << kockica2;
  271.         racunalo_kocka_score = kockica2;
  272.  
  273.         cout << "\n\n\tBacite s tipkom 1: ";
  274.         cin >> baci_kockicu;
  275.         int kockica3 = rand() % 6 + 1;
  276.         cout << "\t" << name << " - kockica: " << kockica3;
  277.         if (kockica3 > korisnik_kocka_score) {
  278.             korisnik_kocka_score = kockica3;
  279.         }
  280.  
  281.         cout << "\n\tRacunalo ";
  282.         int kockica4 = rand() % 6 + 1;
  283.         cout << "kockica: " << kockica4;
  284.         if (kockica4 > racunalo_kocka_score) {
  285.             racunalo_kocka_score = kockica4;
  286.         }
  287.  
  288.         if (korisnik_kocka_score > racunalo_kocka_score) {
  289.             cout << "\n\n\tPobjedio je " << name << " sa kockicom " << korisnik_kocka_score << endl;
  290.             chipsss += ulog_kockice;
  291.         }
  292.         else if (racunalo_kocka_score > korisnik_kocka_score) {
  293.             cout << "\n\n\tPobjedio je Racunalo sa kockicom " << racunalo_kocka_score << endl;
  294.             chipsss -= ulog_kockice;
  295.         }
  296.         else {
  297.             cout << "\n\n\tIzjednaceno je" << endl;
  298.         }
  299.  
  300.         user_stats(name, money, chipsss);
  301.     }
  302.     else
  303.     {
  304.         cout << "\nNemate dovoljno chipova" << endl;
  305.     }
  306. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement