Question
and this is my code #include #include using namespace std; void singleplayer(int choose); void multiplayer(int p1, int p2); int computer, n, player1, player2; char response,
and this is my code
#include
#include
using namespace std;
void singleplayer(int choose);
void multiplayer(int p1, int p2);
int computer, n, player1, player2;
char response, game;
int main()
{
while (response = 'Y' || response == 'y')
{
cout
cin >> game;
if (game == 's' || game == 'S')
{
cout
cin >> player1;
singleplayer(player1);
cout
fflush(stdin);
cin >> response;
}
if (game == 'm' || game == 'M')
{
cout
cin >> player1;
cout
cin >> player2;
multiplayer(player1, player2);
cout
fflush(stdin);
cin >> response;
}
}
return 0;
}
void singleplayer(int choose)
{
while (1){
computer = rand() % 3 + 1;
if (choose == 1 && computer == 3)
{
cout
break;
}
else if (choose == 1 && computer == 2)
{
cout
break;
}
else if (choose == 1 && computer == 1)
{
cout
}
else if (choose == 2 && computer == 1)
{
cout
break;
}
else if (choose == 2 && computer == 3)
{
cout
break;
}
else if (choose == 2 && computer == 2)
{
cout
}
else if (choose == 3 && computer == 1)
{
cout
break;
}
else if (choose == 3 && computer == 2)
{
cout
break;
}
else if (choose == 3 && computer == 3)
{
cout
}
else{
break;
}
while (choose == computer)
{
cout
cin >> choose;
}
}
}
void multiplayer(int p1, int p2)
{
while (1){
if (p1 == 1 && p2 == 3)
{
cout
break;
}
else if (p1 == 1 && p2 == 2)
{
cout
break;
}
else if (p1 == 1 && p2 == 1)
{
cout
}
else if (p1 == 2 && p2 == 1)
{
cout
break;
}
else if (p1 == 2 && p2 == 3)
{
cout
break;
}
else if (p1 == 2 && p2 == 2)
{
cout
}
else if (p1 == 3 && p2 == 1)
{
cout
break;
}
else if (p1 == 3 && p2 == 2)
{
cout
break;
}
else if (p1 == 3 && p2 == 3)
{
cout
}
else{
break;
}
while (p1 == p2)
{
cout
cout
cin >> p1;
cout
cin >> p2;
}
}
}
Based on your solution to 6.24, implement (using functions) the Rock Paper Scissors Spock Lizard game. (as popularized on "The Big Bang Theory" TV show) functions) the Rock Paper Scisors SposkStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started