Rock-Paper-Scissors

Hi everyone,

I have this rock-paper-scissors game I have to do for my c++ class.
We had to use enum type of variable, switch and do while. I had to do the program with all the stuff I put in...but it doesn't work!

Can you please tell me what is wrong?

Here is the 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228

#include <iostream>				// Pour l'utilisation de cin et cout
#include <cstdlib>				// Pour l'utilisation de srand() et rand()
#include <ctime>				// Pour l'utilisation de time()
#include <cctype>				// Pour l'utilisation de toupper()
using namespace std;

void main (void)
{
	enum TypeJeu {ROCK, PAPER, SCISSORS, LIZARD, SPOCK}; // variables de type enumération

	TypeJeu CoupJoueur, CoupOrdi;
	int PointJoueur, PointOrdi, Reponse, y, n;

	srand ((unsigned) time(NULL)) // Précise un germe pour le générateur

		cout << "You are about to play a more evolved and geeky version of the original Rock-Paper-Scissors game\n";
		cout << "Here are the rules\n"; << "Scissors cut Paper\n"; << "Paper covers Rock\n";
		cout << "Rock crushes Lizard\n"; << "Lizard poisons Spock\n"; << "Spock smashes Scissors\n";
		cout << "Scissors decapitate Lizard\n"; << "Lizard eats Paper\n"; << "Paper disproves Spock\n";
		cout << "Spock vaporizes Rock\n"; << "Rock crushes Scissors\n";
		cout << "Now you know the rules. Let's play!\n";

		do 
		{
			cout << "What would you like to play?\n";
			cout << "R-ROCK, P-PAPER, S-SCISSORS, L-LIZARD, K-SPOCK"\n";
			cin >> (toupper(CoupJoueur))

			switch (toupper(CoupJoueur))
			{
			case "R" : 
				CoupOrdi = TypeJeu (rand() % (SPOCK+1));
				switch (CoupOrdi)
				{
				case "ROCK" :	cout << "You chose ROCK/n"; 
								cout << "The computer chose ROCK/n";
								cout << "It's a tie!";
								PointJoueur += 0;
								PointOrdi += 0; break;

				case "PAPER" :	cout << "You chose ROCK/n"; 
								cout << "The computer chose PAPER/n";
								cout << "PAPER covers ROCK. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;
						
				case "SCISSORS" :	cout << "You chose ROCK/n"; 
									cout << "The computer chose SCISSORS/n";
									cout << "ROCK crushes SCISSORS. You win!";
									PointJoueur += 1;
									PointOrdi += 0; break;

				case "LIZARD" : cout << "You chose ROCK/n"; 
								cout << "The computer chose LIZARD/n";
								cout << "ROCK crushes LIZARD. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;

				case "SPOCK" :	cout << "You chose ROCK/n"; 
								cout << "The computer chose SPOCK/n";
								cout << "SPOCK vaporizes ROCK. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;
				}	
			
			case "P" : 
				CoupOrdi = TypeJeu (rand() % (SPOCK+1));
				switch (CoupOrdi)
				{
				case "ROCK" :	cout << "You chose PAPER/n"; 
								cout << "The computer chose ROCK/n";
								cout << "PAPER covers ROCK. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;

				case "PAPER" :	cout << "You chose PAPER/n"; 
								cout << "The computer chose PAPER/n";
								cout << "It's a tie!";
								PointJoueur += 0;
								PointOrdi += 0; break;
						
				case "SCISSORS" :	cout << "You chose PAPER/n"; 
									cout << "The computer chose SCISSORS/n";
									cout << "SCISSORS cut PAPER. You loose!";
									PointJoueur += 0;
									PointOrdi += 1; break;

				case "LIZARD" : cout << "You chose PAPER/n"; 
								cout << "The computer chose LIZARD/n";
								cout << "LIZARD eats PAPER. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;

				case "SPOCK" :	cout << "You chose PAPER/n"; 
								cout << "The computer chose SPOCK/n";
								cout << "PAPER disproves SPOCK. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;
				}	
			
			case "S" : 
				CoupOrdi = TypeJeu (rand() % (SPOCK+1));
				switch (CoupOrdi)
				{
				case "ROCK" :	cout << "You chose SCISSORS/n"; 
								cout << "The computer chose ROCK/n";
								cout << "ROCK crushes SCISSORS. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;

				case "PAPER" :	cout << "You chose SCISSORS/n"; 
								cout << "The computer chose PAPER/n";
								cout << "SCISSORS cut PAPER. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;
						
				case "SCISSORS" :	cout << "You chose SCISSORS/n"; 
									cout << "The computer chose SCISSORS/n";
									cout << "It's a tie!";
									PointJoueur += 0;
									PointOrdi += 0; break;

				case "LIZARD" : cout << "You chose SCISSORS/n"; 
								cout << "The computer chose LIZARD/n";
								cout << "SCISSORS decapitate LIZARD. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;

				case "SPOCK" :	cout << "You chose SCISSORS/n"; 
								cout << "The computer chose SPOCK/n";
								cout << "SPOCK smashes SCISSORS. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;
				}	

			case "L" : 
				CoupOrdi = TypeJeu (rand() % (SPOCK+1));
				switch (CoupOrdi)
				{
				case "ROCK" :	cout << "You chose LIZARD/n"; 
								cout << "The computer chose ROCK/n";
								cout << "ROCK crushes LIZARD. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;

				case "PAPER" :	cout << "You chose LIZARD/n"; 
								cout << "The computer chose PAPER/n";
								cout << "LIZARD eats PAPER. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;
						
				case "SCISSORS" :	cout << "You chose LIZARD/n"; 
									cout << "The computer chose SCISSORS/n";
									cout << "SCISSORS decapitate LIZARD. You loose!";
									PointJoueur += 0;
									PointOrdi += 1; break;

				case "LIZARD" : cout << "You chose LIZARD/n"; 
								cout << "The computer chose LIZARD/n";
								cout << "It's a tie!";
								PointJoueur += 0;
								PointOrdi += 0; break;

				case "SPOCK" :	cout << "You chose LIZARD/n"; 
								cout << "The computer chose SPOCK/n";
								cout << "LIZARD poisons SPOCK. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;
				}	
			case "K" : CoupOrdi = TypeJeu (rand() % (SPOCK+1));
				switch (CoupOrdi)
				{
				case "ROCK" :	cout << "You chose SPOCK/n"; 
								cout << "The computer chose ROCK/n";
								cout << "SPOCK vaporizes ROCK. You win!";
								PointJoueur += 1;
								PointOrdi += 0; break;

				case "PAPER" :	cout << "You chose SPOCK/n"; 
								cout << "The computer chose PAPER/n";
								cout << "PAPER disproves SPOCK. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;
						
				case "SCISSORS" :	cout << "You chose SPOCK/n"; 
									cout << "The computer chose SCISSORS/n";
									cout << "SPOCK smashesSCISSORS. You win!";
									PointJoueur += 1;
									PointOrdi += 0; break;

				case "LIZARD" : cout << "You chose SPOCK/n"; 
								cout << "The computer chose LIZARD/n";
								cout << "LIZARD poisons SPOCK. You loose!";
								PointJoueur += 0;
								PointOrdi += 1; break;

				case "SPOCK" :	cout << "You chose SPOCK/n"; 
								cout << "The computer chose SPOCK/n";
								cout << "It's a tie!";
								PointJoueur += 0;
								PointOrdi += 0; break;
				}	
			cout << "Would you like to play again? (y/n)/n";
			cin >> Reponse

			}

			while ( Reponse == y);

			cout << "Your total:" PointJoueur"/n";
			cout << "Computer's total: PointOrdi"/n";
			if (PointJoueur < PointOrdi)
			{
				cout << "You lost!/n";
			}
			else if (PointJoueur > PointOrdi)
				{
					cout << "You won!/n";
				}
					else
					{					
						cout << "It's a tie!/n";
					}

			System ("PAUSE");
}

That would help me a lot!

Thx
Last edited on
First please put code tags so we can read it better.

"
 
your code here
"

(without the quotes)
Last edited on
kernalSeiden wrote:
First please put code tags so we can read it better.

"
your code here


"

(without the quotes)

I don't think that's what you ment to do.
@The OP:
[code]Your code goes here[/code]
It would also be helpful if you said specifically what is wrong.
@browni3141 - yes, that's what i meant. Looking back, my post makes no sense as written...lol
"Paper disproves Spock".........

wut?
Also this user has posted in french. Maybe he is in the same class as this other poster???
I hope this link helps: http://cplusplus.com/forum/beginner/36901/
Also, "you loose" should be "you lose".
Lol. Loose. Yeah, I'll change that.

And as for "paper disproves spock"...well, I didn't invent the rules.

I don't really get what is wrong. I think I suck at programming.
Topic archived. No new replies allowed.