C++ Casino Game Part 2


Video Link :- 



Source_Code of Only Part 2 :- 

if (a == 2)
        {
            srand(time(0));
            cout << "BET Your Money" << endl
                 << endl;
            cin >> b;

            if (b <= balance && b > 0)
            {
                cout << "Choose a Number Between [1-5] :- ";
                int c;
                cin >> c;

                cout << "LETS SEE YOUR LUCK !!" << endl;
                cout << "                     " << endl;
                usleep(2000000); // 1sec = 1000000 microsec
                int num = (rand() % 5);
                cout << "The Number Choosen By Computer :- " << num << endl;

                if (num == c)
                {
                    cout << endl;
                    cout << "CONGRATULATIONS !!!!" << endl;
                    cout << "     " << endl;
                    balance = balance + b * 2;
                    cout << "You Have Won :--> $" << b * 2 << endl;
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                else
                {
                    cout << "    " << endl;
                    cout << "OOPS ! You Have Won Nothing !!" << endl;
                    cout << "     " << endl;
                    balance = (balance - b);
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                cout << endl;
                cout << endl;
                cout << "[Press 1] :--> If You Like To Try Another Game" << endl;
                cout << "[Press 2] :--> To QUIT" << endl;
                cout << endl;
                cin >> check;
                if (check == 2)
                {
                    cout << "GOODBYE !!!" << endl;
                    break;
                }
                else
                {
                    if (balance > 0)
                    {
                        cout << "LETS PLAY !!!!" << endl
                             << endl;
                    }
                    else
                    {
                        cout << " SORRY YOU HAVE NO BALANCE " << endl;
                        break;
                    }
                }
            }

            else if (b < 0)
            {
                cout << "You Cannot Place A Bet in Negative" << endl;
            }
            else
            {
                cout << "You Cannot PLace A Bet More Than Your Current Balance " << endl;
            }
        }


Full Code Till Part 2 :- 

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <unistd.h>
#include <algorithm> // for std::find
#include <iterator>  //for std::begin , std::end

using namespace std;
int main()
{
    int balance = 1000;
    cout << "**************** WELCOME TO CASINO GAME ************************" << endl;
    cout << "**************** Developed by scientificoder ********************" << endl;

    while (true)
    {
        cout << "You currently have $" << balance << endl;
        cout << "Which game would you like to play :- " << endl;
        cout << "                                         " << endl;
        cout << "1. [7.7.7] Casino --> Vegas Slot Game " << endl;
        cout << "2. Guess The Number Between [1 - 5] " << endl;
        cout << "3. Roulette :- Bet On Your Numbers " << endl;
        cout << "                                     " << endl;
        cout << "Press [1] , [2] , [3]" << endl;
        int a, b, check;
        cin >> a;

        if (a == 1)
        {
            srand(time(0)); // Initialize random number generator
            cout << "BET Your Money" << endl;
            cin >> b;

            if (b <= balance && b > 0)
            {
                cout << "LETS SEE YOUR LUCK !!" << endl;
                cout << "                     " << endl;
                usleep(2000000); // 1sec = 1000000 microsec

                int num1 = (rand() % 10);
                int num2 = (rand() % 10);
                int num3 = (rand() % 10);
                cout << num1 << "   " << num2 << "   " << num3 << "   " << endl;

                if (num1 % 2 == 0 && num2 % 2 == 0 && num3 % 2 == 0)
                {
                    cout << "    " << endl;
                    cout << "CONGRATULATIONS !!!!" << endl;
                    cout << "     " << endl;
                    balance = balance + b * 2;
                    cout << "You Have Won :--> $" << b * 2 << endl;
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                else if (num1 % 2 != 0 && num2 % 2 != 0 && num3 % 2 != 0)
                {
                    cout << "    " << endl;
                    cout << "CONGRATULATIONS !!!!" << endl;
                    cout << "     " << endl;
                    balance = balance + b * 2;
                    cout << "You Have Won :--> $" << b * 2 << endl;
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                else if (num1 == num2 && num2 == num3 && num3 == num1)
                {
                    cout << "    " << endl;
                    cout << "CONGRATULATIONS !!!!" << endl;
                    cout << "     " << endl;
                    balance = balance + b * 5;
                    cout << "You Have Won :--> $" << b * 5 << endl;
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }
                else if (num1 == 7 && num2 == 7 && num3 == 7)
                {
                    cout << "    " << endl;
                    cout << "CONGRATULATIONS !!!!" << endl;
                    cout << "     " << endl;
                    balance = balance + b * 10;
                    cout << "You Have Won :--> $" << b * 10 << endl;
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                else
                {
                    cout << "    " << endl;
                    cout << "OOPS ! You Have Won Nothing !!" << endl;
                    cout << "     " << endl;
                    balance = (balance - b);
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                cout << endl;
                cout << endl;
                cout << "[Press 1] :--> If You Like To Try Another Game" << endl;
                cout << "[Press 2] :--> To QUIT" << endl;
                cout << endl;
                cin >> check;
                if (check == 2)
                {
                    cout << "GOODBYE !!!" << endl;
                    break;
                }
                else
                {
                    if (balance > 0)
                    {
                        cout << "LETS PLAY !!!!" << endl
                             << endl;
                    }
                    else
                    {
                        cout << " SORRY YOU HAVE NO BALANCE " << endl;
                        break;
                    }
                }
            }

            else if (b < 0)
            {
                cout << "You Cannot Place A Bet in Negative" << endl;
            }
            else
            {
                cout << "You Cannot PLace A Bet More Than Your Current Balance " << endl;
            }
        }

        if (a == 2)
        {
            srand(time(0));
            cout << "BET Your Money" << endl
                 << endl;
            cin >> b;

            if (b <= balance && b > 0)
            {
                cout << "Choose a Number Between [1-5] :- ";
                int c;
                cin >> c;

                cout << "LETS SEE YOUR LUCK !!" << endl;
                cout << "                     " << endl;
                usleep(2000000); // 1sec = 1000000 microsec
                int num = (rand() % 5);
                cout << "The Number Choosen By Computer :- " << num << endl;

                if (num == c)
                {
                    cout << endl;
                    cout << "CONGRATULATIONS !!!!" << endl;
                    cout << "     " << endl;
                    balance = balance + b * 2;
                    cout << "You Have Won :--> $" << b * 2 << endl;
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                else
                {
                    cout << "    " << endl;
                    cout << "OOPS ! You Have Won Nothing !!" << endl;
                    cout << "     " << endl;
                    balance = (balance - b);
                    cout << "YOUR CURRENT BALANCE --> $" << balance << endl;
                }

                cout << endl;
                cout << endl;
                cout << "[Press 1] :--> If You Like To Try Another Game" << endl;
                cout << "[Press 2] :--> To QUIT" << endl;
                cout << endl;
                cin >> check;
                if (check == 2)
                {
                    cout << "GOODBYE !!!" << endl;
                    break;
                }
                else
                {
                    if (balance > 0)
                    {
                        cout << "LETS PLAY !!!!" << endl
                             << endl;
                    }
                    else
                    {
                        cout << " SORRY YOU HAVE NO BALANCE " << endl;
                        break;
                    }
                }
            }

            else if (b < 0)
            {
                cout << "You Cannot Place A Bet in Negative" << endl;
            }
            else
            {
                cout << "You Cannot PLace A Bet More Than Your Current Balance " << endl;
            }
        }
    }

    return 0;
}
//Subscribe scienitificoder for mast mast projects
// Thank YOU






























































































































































No comments:

Post a Comment