/******************************************************************************************
**When the program begins, a random number in the range of 1 through 3 is generated.
**If the number is 1, then the computer has chosen rock.
**If the number is 2, then the computer has chosen paper.
**If the number is 3, then the computer has chosen scissors.
**Then the user enters his or her choice of "rock", "paper", or "scissors" at the keyboard.
*******************************************************************************************/
#include <iostream>
#include <ctime>
#include <cstdlib>
usingnamespace std;
int main()
{
system("color D5");
srand(time(NULL)); //seeds the generator
int rand_num;
rand_num = rand()%3+1;
int choice;
cout << "* * * * * * * * * * * * * * * * * * * * * * * * * * * " << endl
<< "Welcome to Megatron's Rock, Paper, Scissors game." << endl
<< "* * * * * * * * * * * * * * * * * * * * * * * * * * * " << endl <<endl
<< " Would you like to play" <<endl
<< "(Y for yes and N for NO)" << endl;
char play;
cin >> play;
while (play == 'y' || play == 'Y' )
{
cout << "Can you beat Megratron?" << endl
<< "(Type 0 for Rock, 1 for Paper or 2 for Scissors)" << endl << endl;
cin >> choice;
// get choice from the user
//compare choice to the rand
//display results
//play again
while (choice == 1)
{
if (rand_num == 2)
cout << "Paper beats rock! Sorry, you lose!\n\n\n\n";
elseif (rand_num == 3)
cout << "Rock beats scissors! You win!\n\n\n\n";
elseif (rand_num == 1)
cout << "It's a tie!\n\n\n\n";
}
if (choice == 2)
{
if (rand_num == 2)
cout << "Paper beats rock! You win!\n\n\n\n";
elseif (rand_num == 3)
cout << "Scissors beat paper! Megatron wins!\n\n\n\n";
elseif (rand_num == 1)
cout << "It's a tie!\n\n\n\n";
}
if (choice == 3)
{
if (rand_num == 2)
cout << "Scissors beat paper! You win!\n\n\n\n";
elseif (rand_num == 3)
cout << "Rock beats scissors! Sorry, you lose!\n\n\n\n";
elseif (rand_num == 1)
cout << "It's a tie!\n\n\n\n";
}
else
cout << "invalid input, please try again" <<endl;
}
cout << "program now closing" <<endl;
return 0;
}