1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void starting_Money_Verify (long int starting_Money);
void bet_menu (long int *ptr, long int starting_Money);
int take_Bet (long int adjusted_Money, int bet_Amount, int bet_Again);
int money_Remaining (long int total_Money, int bet_Amount);
int _tmain(int argc, _TCHAR* argv[])
{
/***************************************************************
*starting_Money cannot be greater than 1,000,000
*num_Bets cannot exceed 8
*bet_Amount cannot exceed 500
***************************************************************/
long int starting_Money= 0, total_Money = 0, *array_ptr;
array_ptr = new long int[8];//Dynamic array
cout << "How much money are you coming to the table with?: $";
cin >> starting_Money;
starting_Money_Verify (starting_Money); //Passes the starting_Money to 'starting_Money_Verify' fuction.
bet_menu(array_ptr, starting_Money); //Passes array_ptr and starting_Money to 'bet_Menu' function.
delete[] array_ptr; //Delet the dynamic array at the end of the function.
system("pause");
return 0;
}
/*******************************************************
*This function is passed into the main function.
*It displays the bet menu list, and takes the bet
*from the user.
*******************************************************/
void bet_menu ( long int *ptr, long int starting_Money)
{
int single_Number, num_bets, bet_Again = 1, choice, bet_Amount = 0, total_Money;
while ((bet_Again == 1) || (total_Money > 0))
{
total_Money = total_Money - bet_Amount;
money_Remaining (total_Money, bet_Again); //Passes starting_Money and bet_Again into 'money_Remaining' function.
for (num_bets = 0; num_bets < 8; num_bets++)
{
ptr[num_bets] = total_Money;
cout << "Bet Menu:\n";
cout << "1: Single Bet \n2: All Red Numbers \n3: All Black Numbers \n4: All Even Numbers \n5: All Odd Numbers \n6: First 12 \n7: Second 12 \n8: Third 12 \n9: First Column \n10: Second Column \n11: Third Column \n0: No bet\n";
cout << "-------------------------------------------------" << endl << "You have $" <<total_Money << " remaining to bet." << endl <<"Enter a selection for bet " << num_bets << ": ";
cin >> choice;
switch (choice)//Switch menu layout for betting choices
{
case 1 : cout << "You have chosen a single number bet.\n";
cout << "What number would you like to bet on? You can bet from 0 - 36: ";
cin >> single_Number;
while ((single_Number < 0) || (single_Number > 36))
{
cout << "You can only bet on numbers from 0 to 36.\nPlease enter a number from 0 - 36: ";
cin >> single_Number;
}
system ("CLS");
take_Bet(starting_Money, bet_Amount, bet_Again);
if (bet_Again == 0)
goto endloop;
break;
}
}
}
endloop:;
}
int money_Remaining (long int total_Money, int bet_Amount)
{
total_Money = total_Money - bet_Amount;
return total_Money;
}
int take_Bet (long int adjusted_Money, int bet_Amount, int bet_Again)
{
cout << "Enter the dollar amount you would like to bet: $";
cin >> bet_Amount;
money_Remaining (adjusted_Money, bet_Amount);
system ("CLS");
cout << adjusted_Money << endl;
if (adjusted_Money == 0) //Exit the loop sequence if user runs out of money
{
cout << "You have no more money to bet! Betting phase ending.\n";
bet_Again = 0;
cin.get();
system ("CLS");
}
else if (adjusted_Money < 0)//Exit the loop sequence if user runs out of money
{
cout << "You cannot bet more than you have left, your last bet is invalid.\nBetting phase ending.\n";
bet_Again = 0;
cin.get();
system ("CLS");
}
return bet_Again, adjusted_Money;
}
|