Craps Game

I need help developing this craps game. Whenever I compile the program it will simulate the dice but it will output more than one outcome of the if else statements I have. When I win the game it will not add the value I have bet as well to my purse. Any help is much appreciated.

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
//*****************************************************************************

#include <iostream>
#include<cstdlib>
#include<fstream>
#include<iomanip>
#include<cctype>
#include "random2.cpp"

void rolldice(int& die1, int& die2);
//******************************************************************************

using namespace std;
            
int main()

{                                                                 
const int LUCKY_SEVEN = 7,
           CRAPS = 7,
           YO_LEVEN = 11,
           SNAKE_EYES = 2,
           TREY = 3,
           BOX_CARS = 12;
          

int die1, die2, die_Sum, game_Stat;
die_Sum =( die1 + die2);

           


string name;

double purse = 1000;
string bet;
char again;

double seed1;
double seed2;
int random(double seed1);
int random(double seed2);


 int Win= ((LUCKY_SEVEN) || (YO_LEVEN));
 int Lose= ((SNAKE_EYES) || (TREY) || (BOX_CARS));

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<<"Please enter your name:\n";
getline (cin, name);


do
{
 int Win= ((LUCKY_SEVEN) || (YO_LEVEN));
 int Lose= ((SNAKE_EYES) || (TREY) || (BOX_CARS));
 
double purse = 1000;
double bet;

cout<<"Hello "<<name<<" enter two values between 0 and 1 seperated by a space:\n";
cin>>seed1>>seed2;
die1= random(seed1);
die2= random(seed2);
die_Sum =( die1 + die2);


cout<<"Please enter a valid bet, your bet must be less than or equal to the\n"
    <<"amount of money you have in your purse. You will start with\n"
    <<"$"<< purse <<".\n";
     cin>>bet;
{
if ( bet < purse)
cout<<"Let us begin by rolling the dice.\n";

else if ( bet > purse )
cout<<"You cannot wager that amount of money, please enter a valid bet:\n";
}
{
if ( game_Stat= Win)
purse+= bet;

else if (game_Stat=Lose)
purse-= bet;                    
}
{     
if (die_Sum == LUCKY_SEVEN)
game_Stat= Win;
purse= purse + bet;
cout<<"You've rolled a lucky 7(Big Red), you've won!"<< bet <<".\n"
    <<"With the cash you've won, you now have"<< purse <<"dollars left.\n";
}
{
if (die_Sum == BOX_CARS)
game_Stat= Win;
purse= purse + bet;
cout<<"You've rolled a 12(Boxcars), you win"<< bet <<"dollars! With the cash\n"
    <<"you have just won, you have"<< purse <<"dollars left.\n";
}
{

if ((die_Sum == 2) || (die_Sum == 6))
game_Stat= Lose;
purse= purse - bet;
cout<<"You lose $"<< bet <<", your luck has grown sparse. You now have"<< purse<<endl;
}


cout<<"Would you like to play this game again, enter Y-(Yes) or N-(No):\n";
cin>> again;
again = toupper(again);




}while ( again == 'Y');

 
return 0;
}
Your program will not work the way you think it will...for example:

die_Sum =( die1 + die2);
This will set die_Sum to die1 + die2 ONCE. It will not update if die1 or die2 change. Also, your winning conditions are not correct. The || operator takes one bool on each side, so you will get stuff like 7 || 10, which give you true || true, and it will set the "winning" value to 1 (most likely).
int Win= ((LUCKY_SEVEN) || (YO_LEVEN));

wtf does that do? you're setting Win to LUCKY_SEVEN OR YO_LEVEN ??
Last edited on
Yeah, i'm an amateur. I'm trying to justify what numbers will win and lose. So if you roll a seven the first roll then a 7 the next you lose, right... I''ve actually never played craps so it makes it even harder to develop any program without it logically making sense. So please more feedback is welcomed.
You can just use int like that. You will have to use an if() statement specifically where you want it to be...or it could be that you are looking for something like this:

#define WIN (LUCKY_SEVEN || YO_LEVEN)
Topic archived. No new replies allowed.