kramer
10-02-2007, 08:22 PM
can anyone help me turn this 2 player game of paper, rock and scissor into a player versus computer type?please..i badly need it..
# include <iostream>
using namespace std;
int main () {
char a,b;
int d,e;
char ans;
do {
cout << "This is a game called Jack en Poy\n";
cout <<"Player *, please select your move:" << endl
<< "*. Rock" << endl
<< "2. Scissors" << endl
<< "*. Paper";
cout << "What is your move?\n";
cin >> d;
if (d==*) {
cout << "Player *'s move is rock.";
}
else if (d==2){
cout << "Player *'s move is scissors.";
}
else if (d==*){
cout << "Player *'s move is paper.";
}
cout << "\nPlayer 2, please select your move:"<< endl
<< "*. Rock" << endl
<< "2. Scissors" << endl
<< "*. Paper";
cout << "\nWhat is your move?\n";
cin >> e;
if (e==*) {
cout << "Player *'s move is rock.";
}
else if (e==2){
cout << "Player *'s move is scissors.";
}
else if (e==*){
cout << "Player 2's move is paper.";
}
cout << "\nThe result is: \n";
if (d==* && e==*){
cout << "It is a tie!";
}
else if (d==2 && e==2) {
cout << "It is a tie!";
}
else if (d==* && e==*) {
cout << "It is a tie!";
}
else if (d==* && e==2){
cout << "Player * wins!";
}
else if (d==* && e==*) {
cout << "Player 2 wins!";
}
else if (d==2 && e==*) {
cout << "Player * wins!";
}
else if (d==2 && e==*){
cout << "Player 2 wins!";
}
else if (d==* && e==*) {
cout << "Player * wins!";
}
else if (d==* && e==2) {
cout << "Player 2 wins!";
}
cout << "\nRun the program again?(y/n)\n";
cin >> ans;
} while (ans!='n');
return 0;
}
:confused:
# include <iostream>
using namespace std;
int main () {
char a,b;
int d,e;
char ans;
do {
cout << "This is a game called Jack en Poy\n";
cout <<"Player *, please select your move:" << endl
<< "*. Rock" << endl
<< "2. Scissors" << endl
<< "*. Paper";
cout << "What is your move?\n";
cin >> d;
if (d==*) {
cout << "Player *'s move is rock.";
}
else if (d==2){
cout << "Player *'s move is scissors.";
}
else if (d==*){
cout << "Player *'s move is paper.";
}
cout << "\nPlayer 2, please select your move:"<< endl
<< "*. Rock" << endl
<< "2. Scissors" << endl
<< "*. Paper";
cout << "\nWhat is your move?\n";
cin >> e;
if (e==*) {
cout << "Player *'s move is rock.";
}
else if (e==2){
cout << "Player *'s move is scissors.";
}
else if (e==*){
cout << "Player 2's move is paper.";
}
cout << "\nThe result is: \n";
if (d==* && e==*){
cout << "It is a tie!";
}
else if (d==2 && e==2) {
cout << "It is a tie!";
}
else if (d==* && e==*) {
cout << "It is a tie!";
}
else if (d==* && e==2){
cout << "Player * wins!";
}
else if (d==* && e==*) {
cout << "Player 2 wins!";
}
else if (d==2 && e==*) {
cout << "Player * wins!";
}
else if (d==2 && e==*){
cout << "Player 2 wins!";
}
else if (d==* && e==*) {
cout << "Player * wins!";
}
else if (d==* && e==2) {
cout << "Player 2 wins!";
}
cout << "\nRun the program again?(y/n)\n";
cin >> ans;
} while (ans!='n');
return 0;
}
:confused: