Craps game in C++

When I run it, I can get it to ask how much to bet then play once and then ask the user if they want to play again or not. But I'm having trouble after that. It will play after that but will not follow the rules that I specify and then it will only play once. I'm not sure of how to fix this and have been trying for quite a while now. Just want some fresh eyes and guidance on this.

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
 #include <iostream>
#include <cstdlib>

using namespace std;

int dice();
int game();
int money(int, int);
bool outcome;
int bet;
int saved;
int main(){
	char decision;
	int saved = 10000;
	outcome = false;
	cout << "Hello and welcome to the Craps table. You have $" << saved << endl;
	cout << "Would you like to test your luck? [Y/N]" << endl;
	cin >> decision;
	switch (decision){
	case 'Y': case 'y':
		cout << "May lady luck's fortune be ever in your favor!\n";
			 money( bet,saved);
			break;
	case 'N': case 'n':
		cout << "Was a pleasure playing with you. Hope you come back soon!\n";
		return 0;
		break;
	default:
		cout << "Oh, come on now. Seriously now, want to play or not?\n";
		cin.clear();
		main();
		break;
		}
	
	return 0;
}

int dice(){
	int die1 = (1 + rand() % 6);
	int die2 = (1 + rand() % 6);
	int total = die1 + die2;
	cout << "You rolled a " << die1 << " and a " << die2 << " which in total is " << total << endl;
	return total;
}
int money(int bet, int saved){
	char play = 0;
	cout << "You have $" << saved << endl;
	cout << "How much would you like to bet?\n";
	cin >> bet;
	if (bet > saved){
		cout << "Sorry, appears you don't have that much money. How about a smaller amount?" << endl;
		cin.clear();
		money(bet, saved);
	}
	game();
	if (outcome == true){
		saved = +(bet * 2);
		cout << "You now have $" << saved << endl;
		cout << "Would you like to keep playing? [Y/N]" << endl;
		cin >> play;
		switch (play){
		case'y': 
			money(bet, saved);
			break;
		case 'Y':
			money(bet, saved); 
			break;
		case'n':
			cout << "Was a pleasure playing with you. Hope you come back soon!\n";
			return 0;
		case'N':
			cout << "Was a pleasure playing with you. Hope you come back soon!\n";
			return 0;
		default:
			cout << "Oh, come on now. Seriously now, want to play or not?\n";
			cin >> play;
			break;
		}
	}
	else{
		if (outcome == false){
			saved -=bet;
			cout << "You still have $" << saved << endl;
			cout << "Would you like to keep playing? [Y/N]" << endl;
			cin >> play;
			switch (play){
			case'y': case 'Y':
				game();
				break;
			case'n': case'N':
				cout << "Was a pleasure playing with you. Hope you come back soon!\n";
				return 0;
			default:
				cout << "Oh, come on now. Seriously now, want to play or not?\n";
				cin >> play;
				break;
			}
		}

	}
}

int game(){
	int froll = 0, roll = 0, point = 0;
	bool outcome = false;
	froll = dice();
	if (froll == 7 || froll == 11){
		cout << "Congratulations! You win!" << endl;
		outcome = true;
		

	}
	else if (froll == 2 || froll == 3 || froll == 12){
		cout << "So sorry, better luck next time" << endl;
		outcome = false;
		 

	}
	else{
		point = froll;
		cout << "Point is " << point << endl;
		while (outcome == false){
			roll = dice();
			if (roll == point){
				cout << "Congratulations! You win!" << endl;
				outcome = true;
				}
			else if (roll == 7){
				cout << "So sorry, better luck next time" << endl;
				outcome = false;
				
			}
		}

	}
	
	return outcome;
	money(bet, saved);
}
Morning,
i don't know if this is any use to you but:
1
2
	return outcome;  // <- you are returning here so the following line will never be called
	        money(bet, saved);




Evening around these parts. Thanks for the quick reply.
When I swap the two statements, I end up being able to play the game repeatedly but, it stores the wrong amount of money for saved and also doesn't go through the money function to test wither outcome is true or not.
Ok so I got it to repeat properly by separating the outcome tests from the money function. so it is now:
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
int money(int bet, int saved){
	char play = 0;
	cout << "You have $" << saved << endl;
	cout << "How much would you like to bet?\n";
	cin >> bet;
	saved = saved - bet;
	if (bet > saved){
		cout << "Sorry, appears you don't have that much money. How about a smaller amount?" << endl;
		cin.clear();
		money(bet, saved);
	}


	game();
	return(bet, saved);
}
int game2() {
	saved = 10000;
	saved = saved - bet;
	if (outcome == true){
		saved = saved+(bet * 2);
		cout << "You now have $" << saved << endl;
		cout << "Would you like to keep playing? [Y/N]" << endl;
		cin >> play;
		switch (play){
		case'y':
			money(bet, saved);
			break;
		case 'Y':
			money(bet, saved);
			break;
		case'n':
			cout << "Was a pleasure playing with you. Hope you come back soon!\n";
			return 0;
		case'N':
			cout << "Was a pleasure playing with you. Hope you come back soon!\n";
			return 0;
		default:
			cout << "Oh, come on now. Seriously now, want to play or not?\n";
			cin >> play;
			break;
		}

	}
	else{
		if (outcome == false){
			saved = saved-bet;
			cout << "You still have $" << saved << endl;
			cout << "Would you like to keep playing? [Y/N]" << endl;
			cin >> play;
			switch (play){
			case'y': case 'Y':
				cout << "How much would you like to bet?\n";
				cin >> bet;
				game();
				break;
			case'n': case'N':
				cout << "Was a pleasure playing with you. Hope you come back soon!\n";
				return 0;
			default:
				cout << "Oh, come on now. Seriously now, want to play or not?\n";
				cin >> play;
				break;
			}
		}
		return(saved, bet);
	}
}


But now I can't figure out what's stopping the program from keeping accurate count of the money saved.
what's this:
return(saved, bet);
?
Topic archived. No new replies allowed.