|
-
August 17th, 2012, 07:55 AM
#1
rock paper scissors game
i am just about to finish my rock papper sissors game as i added classes to the games. however i dont know how to add a scoring system. any help.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
class Rock
{
int choice;
int compchoice;
public:
void Game();
};
void Rock::Game()
{
srand((unsigned)time(0));
compchoice = (rand()%2)+1;
cout << "Welcome to Rock Paper Scissors.";
cout << " You will be playing against the computer. Type 1 for";
cout << " rock, 2 for paper, and 3 for scissors\n";
cin >> choice;
if (choice == 1)
{
cout <<" . -- ~~~ -- .\n";
cout <<" .-~ ~-.\n";
cout <<" / \\n";
cout <<" / \\n";
cout <<" | |\n";
cout <<" | |\n";
cout <<" | |\n";
cout <<" \ /\n";
cout <<" \ /\n";
cout <<" `-. .-'\n";
cout <<" ~- . ___ . -~\n";
if (compchoice == 1)
cout << "It's a tie!\n\n\n\n";
else if (compchoice == 2)
cout << "Paper beats rock! Sorry, you lose!\n\n\n\n";
else if (compchoice == 3)
cout << "Rock beats scissors! You win!\n\n\n\n";
}
if (choice == 2)
{
cout <<" ____________\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" | __________ |\n";
cout <<" |____________|\n";
if (compchoice == 1)
cout << "It's a tie!\n\n\n\n";
else if (compchoice == 2)
cout << "Paper beats rock! You win!\n\n\n\n";
else if (compchoice == 3)
cout << "Scissors beat paper! Sorry, you lose!\n\n\n\n";
}
if (choice == 3)
{
cout <<" ___ ___\n";
cout <<" / _ \ / _ \\n";
cout <<" / / \ \ / / \ \\n";
cout <<" \ \_/ / \ \_/ /\n";
cout <<" \___/ \___/\n";
cout <<" \ \ / /\n";
cout <<" \ O /\n";
cout <<" // \\\n"; //" << endl;
cout <<" // \\\n";
cout <<" // \\\n";
cout <<" // \\\n";
cout <<" // \\\n";
cout <<" // \\\n";
cout <<" // \\\n";
cout <<"/ \\n";
if (compchoice == 1)
cout << "It's a tie!\n\n\n\n";
else if (compchoice == 2)
cout << "Scissors beat paper! You win!\n\n\n\n";
else if (compchoice == 3)
cout << "Rock beats scissors! Sorry, you lose!\n\n\n\n";
}
}
int main()
{
Rock Main;
Main.Game();
return main();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|