Casino Betting Game

I am trying to create a casino game using functions that allows the user to play any of 4 games as many times as they want.

The first game is High-Low where the computer generates a random number between 1 and 10 and the user tries to guess whether the 2nd random number will be higher or lower than the first.

The second game is 21 where the user is assigned two random numbers between 1 and 10 and is asked to hit or stay. Then the computer generates it's own random number between 16 and 23. If it's above 21 the user wins; if it's below 21, but higher than the user's, the computer wins.

The third game is Craps where the computer asks the user whether they want to bet on “Pass” or “No Pass”. The computer then generates two numbers between 1 and 6 (representing two dice being rolled) and displays them to the user.
If the sum of the two numbers is 2, 3 or 12 (“craps”):
and the user bet on “Pass” then the user loses automatically.
and the user bet on “No Pass” then the user wins automatically.
If the sum of the two numbers is 7 or 11 (“a natural”)
and the user bet on “Pass” then the user automatically wins.
and the user bet on “No Pass” then the user automatically loses.
If the sum is anything else (4, 5, 6, 8, 9, or 10) then the computer starts a loop and repeatedly generates new dice rolls until the new dice rolls come up the same sum as before or a sum of 7.
If the new dice roll sums to 7
and the user bet on “Pass”, then the user loses.
and the user bet on “No Pass”, then the user wins.
If the new dice roll matches the sum generated on the first turn,
and the user bet on “Pass”, then the user wins.
and the user bet on “No Pass”, then the user loses.


The fourth game is the Slots where the computer should randomly generate three numbers between 0-9 and display them for the user to see. If all three of the numbers are the same, then the game pays 99 times the betting amount (payoff = 99). If just two of the three match, then the game pays 10 times the betting amount (payoff = 10).

There is a fifth option to Run Test Cases, which is supposed to test the code in the program and do things like:
Validate bank balance
Update bank balance with a win
Update bank balance with a loss
Update bank balance with a negative number (should result in error message)
Prompt the user to determine how many times they want to test the Slots function
Loop through the input number of times
Call the play slots game with a random bet

And the 6th option is to leave the casino.

Here is what I have so far:

#include <iostream>
#include <string>
#include <ctime>
using namespace std;

void mainMenu() { // Gives the user the starting menu
cout << "Welcome to the Casino." << endl;
cout << "Please select an option from the following list." << endl;
cout << "1. Play High-Low" << endl;
cout << "2. Play 21" << endl;
cout << "3. Play Craps" << endl;
cout << "4. Play the Slots" << endl;
cout << "5. Run Test Cases" << endl;
cout << "6. Leave the Casino" << endl;
}

int getBet(string askForBet) { // Asks the user the amount of money they want to bet on any game

int bettingAmount = 0;

do {
cout << askForBet;
cin >> bettingAmount; // User inputs the amount of money they want to bet here
} while (bettingAmount <= 0);

return bettingAmount;

}

bool HighLow() {

bool result;

int bet = getBet("Welcome to High-Low. How much money would you like to bet on this game? $");

srand(time(0));
int compNum1 = rand() % 10 + 1;
cout << "The first number is " << compNum1 << "." << endl;
cout << "Do you think the second number will be (H)igher or (L)ower than the first?" << endl;
char guess;
cin >> guess;
int compNum2 = rand() % 10 + 1;

if (guess == 'h' || guess == 'H') {
if (compNum2 > compNum1)
result = true;
else
result = false;
}

else if (guess == 'l' || guess == 'L') {
if (compNum1 < compNum2)
result = true;
else
result = false;
}

return result;

}

int main() {

int choice;

mainMenu();
cin >> choice;

int bettingAmount;

switch (choice) {

case 1:
bool HighLow();
break;

case 2:
getBet("Welcome to 21. How much money would you like to bet on this game? $");
break;

case 3:
getBet("Welcome to Craps. How much money would you like to bet on this game? $");
break;

case 4:
getBet("Welcome to the Slots. How much money would you like to put down? $");
break;

case 5:
cout << "Test Cases.";
break;

case 6:
cout << "Thanks for playing. Come back soon." << endl;
break;

default:
cout << "Please enter a number between 1 and 6; inclusive." << endl;
break;

}

system("PAUSE");
}
Topic archived. No new replies allowed.