Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- // deklaracija funkcija
- void welcome(string &name, int &money);
- void user_stats(string name, int money, int chipsss);
- void menu();
- void uplata(int &money, int &chipsss);
- void isplata(int &money, int &chipsss);
- void igre_menu();
- void jednoruki_jack(string name, int &money, int &chipsss);
- void bacanje_kockica(string name, int &money, int &chipsss);
- int main()
- {
- srand(time(NULL));
- string ime;
- int novac, chip = 20, odabir;
- welcome(ime, novac); // unos imena i novca
- do {
- system("cls");
- user_stats(ime, novac, chip); // ispis imena, novca, chipova
- menu(); // glavni menu
- cout << "\tVas odabir: ";
- cin >> odabir;
- switch (odabir)
- {
- case 1:
- uplata(novac, chip);
- break;
- case 2:
- isplata(novac, chip);
- break;
- case 3:
- int odabir_igre;
- system("cls");
- user_stats(ime, novac, chip);
- igre_menu();
- do {
- cin >> odabir_igre;
- switch (odabir_igre) {
- case 1:
- system("cls");
- user_stats(ime, novac, chip);
- jednoruki_jack(ime, novac, chip);
- cout << "\n\t1 - Jednoruki Jack (slot machine)" << endl;
- cout << "\t2 - Bacanje kockica" << endl;
- cout << "\t3 - Double or nothing" << endl;
- cout << "\t0 - Glavni meni" << endl;
- break;
- case 2:
- system("cls");
- user_stats(ime, novac, chip);
- bacanje_kockica(ime, novac, chip);
- cout << "\n\t1 - Jednoruki Jack (slot machine)" << endl;
- cout << "\t2 - Bacanje kockica" << endl;
- cout << "\t3 - Double or nothing" << endl;
- cout << "\t0 - Glavni meni" << endl;
- case 3:
- case 0:
- break;
- default:
- cout << "\n\tOdaberite igre 1 - 3. Za izlaz koristite 0. Vas odabir: ";
- break;
- }
- } while (odabir_igre != 0);
- break;
- case 0:
- break;
- default:
- system("cls");
- user_stats(ime, novac, chip);
- igre_menu();
- cout << "Krivi unos! Odaberite brojeve 1 - 4 ili 0 za izlaz\n";
- break;
- }
- } while (odabir != 0);
- system("pause");
- return 0;
- }
- // --- FUNKCIJE ---
- void welcome(string &name, int &money) {
- cout << "\n\tDobrodosli u C++ CASINO\n" << endl;
- cout << "\tUnesite svoje ime: ";
- cin >> name;
- cout << "\tKoliko novca imate: ";
- cin >> money;
- }
- void user_stats(string name, int money, int chipsss) {
- cout << "\n\tUser: " << name << "\tMoney: " << money << "\tChip: " << chipsss << endl;
- }
- void menu() {
- cout << "\n\t1 - Uplata novca - zamjena za chip-ove - 1 chip = 5 kn" << endl;
- cout << "\t2 - Isplata novca" << endl;
- cout << "\t3 - Odabir igre" << endl;
- cout << "\t4 - High score" << endl;
- cout << "\t0 - Izlaz iz programa" << endl;
- }
- void uplata(int &money, int &chipsss) {
- int potrositi;
- cout << "\n\tKoliko novca zelite zamjeniti za chipove?: ";
- cin >> potrositi;
- if (potrositi <= money)
- {
- chipsss += (potrositi - (potrositi % 5)) / 5;
- money -= potrositi - (potrositi % 5);
- cout << "\tMoney spent: " << potrositi - (potrositi % 5) << "\tNew chips: " << (potrositi - (potrositi % 5)) / 5 << "\n";
- }
- else if (potrositi > money)
- {
- chipsss += (money - (money % 5)) / 5;
- cout << "\tMoney spent: " << money - (money % 5) << "\tNew chips: " << (money - (money % 5)) / 5 << "\n";
- money %= 5;
- }
- system("pause");
- }
- void isplata(int &money, int &chipsss) {
- int koliko_chipova;
- string siguran;
- cout << "\n\tMozete dobiti: " << chipsss * 5 << " novaca za " << chipsss << " chipova" << endl;
- cout << "\n\tKoliko chipova zelite unovciti? ";
- cin >> koliko_chipova;
- if (koliko_chipova > chipsss) {
- cout << "\tNemate toliko chipova\n";
- }
- else
- {
- cout << "\n\tJeste sigurni? DA - nastavak, NE - prekid: ";
- cin >> siguran;
- if (siguran == "DA" || siguran == "da") {
- chipsss -= koliko_chipova;
- money += koliko_chipova * 5;
- cout << "\n\tDobili ste " << koliko_chipova * 5 << " novca za " << koliko_chipova << " chipova\n\n";
- }
- else if (siguran == "NE" || siguran == "ne") {
- cout << "\n\tNiste razmjenili chipove za novac.\n";
- }
- }
- system("pause");
- }
- void igre_menu() {
- cout << "\n\t1 - Jednoruki Jack (slot machine)" << endl;
- cout << "\t2 - Bacanje kockica" << endl;
- cout << "\t3 - Double or nothing" << endl;
- cout << "\t0 - Glavni meni" << endl;
- cout << "\tVas odabir: ";
- }
- void jednoruki_jack(string name, int &money, int &chipsss) {
- int rollaj;
- int slot1;
- int slot2;
- int slot3;
- cout << "\n\tJednoruki Jack! 1 game = 1 money" << endl;
- cout << "\t1 - Roll!" << endl;
- cout << "\t0 - Exit!" << endl;
- cout << "\n\tRoll?: ";
- do {
- cin >> rollaj;
- system("cls");
- switch (rollaj) {
- case 1:
- if (chipsss > 0) {
- slot1 = rand() % 4 + 1;
- slot2 = rand() % 4 + 1;
- slot3 = rand() % 4 + 1;
- if (slot1 == slot2 && slot2 == slot3) {
- chipsss += 15;
- user_stats(name, money, chipsss);
- cout << "\n\tJednoruki Jack! 1 game = 1 money" << endl;
- cout << "\t1 - Roll!" << endl;
- cout << "\t2 - Exit!" << endl;
- cout << "\n\t| " << slot1 << " | " << slot2 << " | " << slot3 << " |";
- cout << "\tYou won 16 moneyz" << endl;
- }
- else {
- chipsss--;
- user_stats(name, money, chipsss);
- cout << "\n\tJednoruki Jack! 1 game = 1 money" << endl;
- cout << "\t1 - Roll!" << endl;
- cout << "\t2 - Exit!" << endl;
- cout << "\n\t| " << slot1 << " | " << slot2 << " | " << slot3 << " |\n";
- }
- cout << "\n\tRoll? ";
- }
- else {
- cout << "\n\tYou dont have money. Return with money.\n";
- cout << "\n\tPress 0 to exit.\n";
- }
- break;
- case 0:
- break;
- default:
- cout << "\n\tWrong entry. 1 - Roll, 0 - Exit\n";
- break;
- }
- } while (rollaj != 0);
- }
- void bacanje_kockica(string name, int &money, int &chipsss) {
- int baci_kockicu;
- int korisnik_kocka_score;
- int racunalo_kocka_score;
- int ulog_kockice;
- cout << "\n\tBacanje kockica!\n\n";
- cout << "\tVas ulog: ";
- cin >> ulog_kockice;
- if (ulog_kockice <= chipsss) {
- cout << "\n\tBacite s tipkom 1: ";
- cin >> baci_kockicu;
- int kockica1 = rand() % 6 + 1;
- cout << "\t" << name << " - kockica: " << kockica1;
- korisnik_kocka_score = kockica1;
- cout << "\n\tRacunalo ";
- int kockica2 = rand() % 6 + 1;
- cout << "kockica: " << kockica2;
- racunalo_kocka_score = kockica2;
- cout << "\n\n\tBacite s tipkom 1: ";
- cin >> baci_kockicu;
- int kockica3 = rand() % 6 + 1;
- cout << "\t" << name << " - kockica: " << kockica3;
- if (kockica3 > korisnik_kocka_score) {
- korisnik_kocka_score = kockica3;
- }
- cout << "\n\tRacunalo ";
- int kockica4 = rand() % 6 + 1;
- cout << "kockica: " << kockica4;
- if (kockica4 > racunalo_kocka_score) {
- racunalo_kocka_score = kockica4;
- }
- if (korisnik_kocka_score > racunalo_kocka_score) {
- cout << "\n\n\tPobjedio je " << name << " sa kockicom " << korisnik_kocka_score << endl;
- chipsss += ulog_kockice;
- }
- else if (racunalo_kocka_score > korisnik_kocka_score) {
- cout << "\n\n\tPobjedio je Racunalo sa kockicom " << racunalo_kocka_score << endl;
- chipsss -= ulog_kockice;
- }
- else {
- cout << "\n\n\tIzjednaceno je" << endl;
- }
- user_stats(name, money, chipsss);
- }
- else
- {
- cout << "\nNemate dovoljno chipova" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement