Hello All,
I need some major help. I have to make a game for my final project. I decided to do Rock, paper, scissors. I need to add 2 arrays, repetition, user defined functions, and an option to quit. Like "type 3 to quit" Please help. Here is my code:
let me know what you think:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>
using namespace std;
int main()
{
ifstream inData;
ofstream outData;
inData.open("a:\\prog.dat");
outData.open("a:\\prog.out");
srand((unsigned)time(0));
int choice;
int compchoice = (rand()%2)+1;
cout << "Are you ready to play Rock, Paper, Scissors?!!";
cout << " Let Start! You opponent will be the computer. Type 0 for";
cout << " rock, 1 for paper, and 2 for scissors\n";
cin >> choice;
if (choice == 0)
{
if (compchoice == 0)
cout << "It's a tie!\n\n\n\n";
else if (compchoice == 1)
cout << "Paper beats rock! Sorry, you lose!\n\n\n\n";
else if (compchoice == 2)
cout << "Rock beats scissors! You win!\n\n\n\n";
}
if (choice == 1)
{
if (compchoice == 0)
cout << "It's a tie!\n\n\n\n";
else if (compchoice == 1)
cout << "Paper beats rock! You win!\n\n\n\n";
else if (compchoice == 2)
cout << "Scissors beat paper! Sorry, you lose!\n\n\n\n";
}
if (choice == 2)
{
if (compchoice == 0)
cout << "It's a tie!\n\n\n\n";
else if (compchoice == 1)
cout << "Scissors beat paper! You win!\n\n\n\n";
else if (compchoice == 2)
cout << "Rock beats scissors! Sorry, you lose!\n\n\n\n";
}
inData.close();
outData.close();
return main();
}