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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
#include <iostream>
#include<cstdlib>
#include<iomanip>
#include "rolldice.cpp"
using namespace std;
int main()
{
char choice = 'Y';
const int LUCKY_SEVEN = 7,
CRAPS = 7,
YO_LEVEN = 11,
SNAKE_EYES = 2,
TREY = 3,
BOX_CARS = 12;
const double MINIMUM = 500.00;
void rolldice(int& die1, int& die2);
int die1, die2, dieSum, point;
bool won, quit;
double purse, bet;
double seed1;
double seed2;
int random(double seed1);
int random(double seed2);
cout<<"This program will simulate the game of craps and will allow you to bet\n"
<<"a certain amount of money. Based on your roll, you will win or lose money.\n"
<<"If on your first roll, you roll a 7 or an 11, you will win (Craps Out!)\n"
<<"Until you Crap Out, you will continue to roll. Your starting amount of\n"
<<"money is $1000. You will win or loose money based upon what you have\n"
<<"wagered. Good luck!.\n\n";
cout<<"You have 1000 dollars, you will be asked to place a bet until\n"
<<"you run out.\n";
do
{
double seed1;
double seed2;
int random(double seed1);
int random(double seed2);
purse=1000;
{
if(purse==0)
cout<<"Please exit the game and restart, you do not have enoough money left...\n";
}
if(dieSum==false)
cout<<"You have "<<purse-bet<<"dollars left!\n";
else if(dieSum==true)
cout<<"You have "<<purse+bet<<"dollars left!\n";
cout<<"Please enter a valid bet, bet must be greater or equal to $500.\n";
cin>>bet;
{
if (bet>=500)
cout<<"Let us start by rolling the dice...\n";
else if (bet<500)
cout<<"The minimum bet is $500, please enter a value greater than 500. \n";
}
cout<<"Enter a three values seperated by a space between 0 and 1 to simulate\n"
<<"the roll of the two dice:\n\n";
cin>>seed1>>seed2;
die1= random(seed1);
die2= random(seed2);
dieSum=(die1+die2);
cout<<"You rolled a "<<die1<<" & "<<die2<<"which adds up to "<<dieSum<<"!\n\n";
const int LUCKY_SEVEN = 7,
CRAPS = 7,
YO_LEVEN = 11,
SNAKE_EYES = 2,
TREY = 3,
BOX_CARS = 12;
switch(dieSum)
{
case LUCKY_SEVEN:
YO_LEVEN: won = true;
break;
case SNAKE_EYES:
TREY:
BOX_CARS: won = false;
break;
default: point = dieSum;
cout<<"Your point becomes your dieSum\n\n";
if (dieSum==true)
{
purse+=bet;
cout<<"You win "<< bet <<" dollars, you now have "<< purse + bet <<" !\n\n";
}
else if (dieSum=false)
purse-=bet;
cout<<"You lose "<< bet <<" you now have "<< purse - bet <<" !\n\n";
}
// You probably only need one do while or while loop here so there can
do
{
cout<<"Would you like to play again?\n";
cin>>choice;
choice = toupper(choice);
if(choice !='Y' && choice != 'N')
cout<<"Illegal response! Please answer Y for Yes or N for No!\n";
}while(choice != 'Y' && choice != 'N');
if(choice=='N')
//quit
else(choice=='Y')
cout<<"Ok then...\n";
}
while( (choice!='Y') && (choice!='N'))
return 0;
}
|