Alright so I have 98% of this code completed everything works. However I need help trying to figure out where the last piece of the code goes. The "Congratulations" Part. I mean I was think about doing something like.
int W;
if (W ==2)
cout << "Congratulations";
But I'm not sure that will work or where I should put it!
Rock, Paper, Scissors, Lizard, Spock! is an extension of the classic rock, paper, scissors game between
two players. This version of the game adds two weapons, Lizard and Spock. The user plays the
computer. The player picks one of the five weapons and the computer’s weapon is chosen randomly
from the five. The outcome is determined based on those choices. It is a tie if the same weapon chosen
by the user and computer. If they are different the outcome is determined as follows. The rationale for
the outcome is in parenthesis.
• Scissors beats Paper (Scissors CUTS Paper)
• Paper beats Rock (Paper COVERS Rock)
• Rock beats Lizard (Rock CRUSHES Lizard)
• Lizard beats Spock! (Lizard POISONS Spock)
• Spock! beats Scissors (Spock SMASHES Scissors)
• Scissors beats Lizard (Scissors DECAPITATES Lizard)
• Lizard beats Paper (Lizard EATS Paper)
• Paper beats Spock! (Paper DISPROVES Spock)
• Spock! beats Rock (Spock VAPORIZES Rock)
• Rock beats Scissors (Rock CRUSHES Scissors)
Write a C++ program that implements Rock, Paper, Scissors, Lizard, Spock! The user will check for valid
input a positive integer between 1 and 5. The user plays until either the user or the computer wins the
best two of three games. Output should look similar to below.
Sample Run:
Welcome! The best 2 of 3 games wins!
Choose:
scissor (1)
rock (2)
paper (3)
lizard (4)
Spock! (5): 1
The computer is scissor. You are scissor too. -It is a draw
Choose:
scissor (1)
rock (2)
paper (3)
lizard (4)
Spock! (5): 4
The computer is rock. You are lizard. (Rock CRUSHES Lizard)- You loose
Choose:
scissor (1)
3
rock (2)
paper (3)
lizard (4)
Spock! (5): 3
The computer is Spock! You are paper. (Paper DISPROVES Spock)- You win
Choose:
scissor (1)
rock (2)
paper (3)
lizard (4)
Spock! (5): 2
The computer is lizard. You are rock. (Rock CRUSHES Lizard)- You win
Congratulations- You beat the computer: 2 games to 1
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 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int PlayerChoice;
cout << "Welcome to Rock, Paper, Scissors, Lizard, Spock." << endl;
cout << "The best of 2 of 3 games Wins!!" << endl;
cout << "Choose: " << endl;
cout << "Scissor (1)" << endl;
cout << "Rock (2)" << endl;
cout << "Paper (3)" << endl;
cout << "Lizard (4)" << endl;
cout << "Spock! (5): "; cin >> PlayerChoice;
int CompChoice;
srand(time(0));
CompChoice = rand() % 5 + 1;
if (CompChoice == 1)
{
CompChoice = 1;
}
else if (CompChoice == 2)
{
CompChoice = 2;
}
else if (CompChoice == 3)
{
CompChoice = 3;
}
else if (CompChoice == 4)
{
CompChoice = 4;
}
else if (CompChoice == 5)
{
CompChoice = 5;
}
if (PlayerChoice == 1)
{
}
else if (PlayerChoice == 2)
{
}
else if (PlayerChoice == 3)
{
}
else if (PlayerChoice == 4)
{
}
else if (PlayerChoice == 5)
{
}
if (PlayerChoice == 1 && CompChoice == 1)
{
cout << "The Computer is Scissors.";
cout << "You are Scissors too.";
cout << "-It is a draw!" << endl;
}
else if (PlayerChoice == 2 && CompChoice == 2)
{
cout << "The Computer is Rock.";
cout << "You are Rock too.";
cout << "-It is a draw!" << endl;
}
else if (PlayerChoice == 3 && CompChoice == 3)
{
cout << "The Computer is Paper.";
cout << "You are Paper too.";
cout << "-It is a draw!" << endl;
}
else if (PlayerChoice == 4 && CompChoice == 4)
{
cout << "The Computer is Lizard.";
cout << "You are a Lizard too.";
cout << "-It is a draw!" << endl;
}
else if (PlayerChoice == 5 && CompChoice == 5)
{
cout << "The Computer is Spock!";
cout << "You are Spock too!";
cout << "-It is a Draw! " << endl;
}
else if (PlayerChoice == 3 && CompChoice == 2)
{
cout << "The Computer is Rock.";
cout << "You are Paper.";
cout << "(Paper COVERS Rock)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 2 && CompChoice == 1)
{
cout << "The Computer is Scissors.";
cout << "You are Rock.";
cout << "(Rock CRUSHES Scissors)";
cout << "-You WIN!";
}
else if (PlayerChoice == 1 && CompChoice == 4)
{
cout << "The Computer is Lizard.";
cout << "You are Scissors.";
cout << "(Scissors DECAPITATES Lizard)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 4 && CompChoice == 5)
{
cout << "The Computer is Spock.";
cout << "You are Lizard.";
cout << "(Lizard POISONS Spock)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 3 && CompChoice == 5)
{
cout << "The Computer is Spock.";
cout << "You are Paper.";
cout << "(Paper DISPROVES Spock)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 4 && CompChoice == 3)
{
cout << "The Computer is Paper.";
cout << "You are Lizard.";
cout << "(Lizard EATS Paper)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 2 && CompChoice == 4)
{
cout << "The Computer is Lizard.";
cout << "You are Rock.";
cout << "(Rock CRUSHES Lizard)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 5 && CompChoice == 2)
{
cout << "The Computer is Rock.";
cout << "You are Spock.";
cout << "(Spock VAPORIZES Rock)";
cout << "-You Win!" << endl;
}
else if (PlayerChoice == 5 && CompChoice == 1)
{
cout << "The Computer is Scissors.";
cout << "You are Spock.";
cout << "(Spock SMASHES Scissors)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 1 && CompChoice == 3)
{
cout << "The Computer is Paper.";
cout << "You are Scissors.";
cout << "(Scissors CUTS Paper)";
cout << "-You WIN!" << endl;
}
else if (PlayerChoice == 2 && CompChoice == 3)
{
cout << "The Computer is Paper.";
cout << "You are Rock.";
cout << "(Paper COVERS Rock)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 1 && CompChoice == 2)
{
cout << "The Computer is Rock.";
cout << "You are Scissors.";
cout << "(Rock CRUSHES Scissors)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 4 && CompChoice == 1)
{
cout << "The Computer is Scissors.";
cout << "You are Lizard.";
cout << "(Scissors DECAPITATES Lizard)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 5 && CompChoice == 4)
{
cout << "The Computer is Lizard.";
cout << "You are Spock.";
cout << "(Lizard POISONS Spock)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 5 && CompChoice == 3)
{
cout << "The Computer is Paper.";
cout << "You are Spock";
cout << "(Paper DISPROVES Spock)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 3 && CompChoice == 4)
{
cout << "The Computer is Lizard.";
cout << "You are Paper.";
cout << "(Lizard EATS Paper)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 4 && CompChoice == 2)
{
cout << "The Computer is Rock.";
cout << "You are Lizard.";
cout << "(Rock CRUSHES Lizard)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 2 && CompChoice == 5)
{
cout << "The Computer is Spock.";
cout << "You are Rock.";
cout << "(Spock VAPORIZES Rock)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 1 && CompChoice == 5)
{
cout << "The Computer is Spock";
cout << "You are Scissors";
cout << "(Spock SMASHES Scissors)";
cout << "-You LOSE!" << endl;
}
else if (PlayerChoice == 3 && CompChoice == 1)
{
cout << "The Computer is Scissors.";
cout << "You are Paper.";
cout << "(Scissors CUTS Paper)";
cout << "-You LOSE!" << endl;
}
cin.get();
return 0;
}
|
Thanks in advance!