Game of craps

Hey guys, I'm trying to make a game of craps right now, but I'm having a few issues.

My first problem is I have no idea how to make it ask for another bet when I want to continue, it just adds/subtracts from the previous total.
Any help would be appreciated.

Second problem is right now when I run my program, it works if my numbers do not = 7 and the yes/no function still works.
But when it does = 7 and it asks to continue its just ends my program.

main code
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
138
139
140
141
142
143
144
145
146
147
148
149
#include <iostream>

using namespace std;

#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "header.h"


void main ()
	{
		int		start (50);
		int		bet (0);
		int		point (0);
		int		total (0);
		bool	a;

		char ans;

		cout << "You have $50. How much will you bet?" <<endl;
		cin >> bet;

		if ((bet < 0 ) || (bet > 50))
			do 
	{	cout << "Invalid bet. Enter another bet. " <<endl;
		cin >> bet;
	}
		while ((bet < 0) || (bet > 50));

		srand (time (0));

		total = ThrowDie () + ThrowDie ();

		switch (total)
	{
			case 7:
			case 11:
				start = start + bet;
				cout << "You rolled " << total << ". You won!" << endl;
				cout << "You now have $" << start << "." << endl;
				
				cout << "Play again? (Y/N)" << endl;
				cin >> ans;

				switch (ans)
				{
				case 'y':
				case 'Y':
					a = true;
						break;
				case 'n':
				case 'N':
					a = false;
					exit (0);
					cout << "Bye" << endl;
						break;
				default:
					cout << "Not valid. Enter another answer" <<endl;
					break;
				}
				{
				while (true);
				}
			case 2:
			case 3:
			case 12:
						start = start - bet;
						cout << "You rolled " << total <<". You lost." << endl;
						cout << "You now have $" << start <<"." << endl;
						cout << "Play again? (Y/N)" << endl;
						cin >> ans;

				switch (ans)
				{
				case 'y':
				case 'Y':
					a = true;
						break;
				case 'n':
				case 'N':
					a = false;
					exit (0);
					cout << "Bye" << endl;
						break;
				default:
					cout << "Not valid. Enter another answer" <<endl;
					break;
				}

			default:
			case 1:
			case 4:
			case 5:
			case 6:
			case 8:
			case 9:
			case 10:
					point = total;
					cout << "You rolled " <<  total << ". Roll again " << endl;
					do
	  {
						total = ThrowDie () + ThrowDie ();
						cout << "You rolled " << total << endl;
						if (total == point)
	  					{
						start = start + bet;
						cout << " You rolled " << total << endl;
						cout << "You won! " << endl;
						cout << "You now have $ " << start << "." << endl;
						cout << "Play again? (Y/N) " << endl;
						cin >> ans;
						}
						
						else if (total == 7);
						{
						start = start - bet;
						cout <<"You lost," << endl;
						cout <<"You now have $ " << start << "." << endl;
						cout <<"Play again? (Y/N)" << endl;
						cin >> ans;
						}

							switch (ans)
				{
				case 'y':
				case 'Y':
					a = true;
						break;
				case 'n':
				case 'N':
					a = false;
					exit (0);
					cout << "Bye" << endl;
						break;
				default:
					cout << "Not valid. Enter another answer" <<endl;
					break;
							}
		
						
	  }
			while (total != point && total !=7);
	  
		}
		

		}


header cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdlib.h>	
#include <time.h>

#include "header.h"

void Initialize ()
	{
	srand (time (0));
	}

int ThrowDie ()
	{
	return (rand () % 6) + 1;
	}

int ThrowDice ()
	{
	return ThrowDie () + ThrowDie ();
	}


header
1
2
3
4
5
6
7
8
#ifndef DICE_H
#define DICE_H

void	Initialize	();
int		ThrowDie	();
int		ThrowDice	();

#endif 


Topic archived. No new replies allowed.