I am getting syntax errors and stuff with this and i am trying to make a program where its rock, paper, scissors where the computer plays the user. any help would be awesome
#include <iostream>
#include <ctime>
using namespace std;
enum Choice { Rock, Paper , Scissors }; // Rock=0, Paper=1, Scissors=2
enum Decision { Draw, Win, Lose }; // Draw=0, Win=1, Lose=2
char DoMenu();
void CheckWinner (int PlayerChoice);
int main()
{
// Use computers random choice generator
srand(time(0));
// declare variables
char choice;
do
{
choice = DoMenu();
switch (choice)
{
case 'R': // fall through
case 'r': cout << "\nPlayer: Rock\n"; CheckWinner(Rock); break;
case 'P': // fall through
case 'p': cout << "\nPlayer: Paper\n"; CheckWinner(Paper); break;
case 'S': // fall through
case 's': cout << "\nPlayer: Scissors\n"; CheckWinner(Scissors); break;
default : cout << "\n";
}
} while ((choice != 'Q') && (choice != 'q'));
// end program
return 0;
}
char DoMenu()
{
char MenuChoice;
cout << "(R)ock\n";
cout << "(P)aper\n";
cout << "(S)cissors\n";
cout << "----------\n";
cout << "Choice: ";
cin >> MenuChoice;
return MenuChoice;
}
void CheckWinner(Choice PlayerChoice)
{
int random = rand()%3;
switch (random)
{
case Rock: cout << "Computer: Rock\n"; break;
case Paper: cout << "Computer: Paper\n"; break;
case Scissors: cout << "Computer: Scissors\n"; break;
}
}
if (PlayerChoice == Paper);
{
switch (random)
{
case Rock: outcome = Win; break;
case Paper: outcome = Draw; break;
case Scissors: outcome = Lose; break;
}
}
if (PlayerChoice == Scissors);
{
switch (random)
{
case Rock: outcome = Lose; break;
case Paper: outcome = Win; break;
case Scissors: outcome = Draw; break;
}
}
switch (outcome);
{
case Win: cout << "Player Wins!\n\n"; break;
case Lose: cout << "Player Loses!\n\n"; break;
case Draw: cout << "Draw\n\n"; break;
}