Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- #include <algorithm>
- using namespace std;
- int main() {
- //declartions
- srand (time(NULL));
- string a, b;
- int r, ws;
- ws = 0; //win streak
- //game logic
- while (true) {
- cout << "\n" << endl;
- cout << "AS YOUR OPPONENT READYS HIS HAND YOU READY YOURS!\nROCK, PAPER OR SCISSORS?" << endl;
- a = ""; //input varible
- b = ""; //villians hand
- r = (rand() % 3) + 1;
- while (a != "ROCK" && a != "PAPER" && a != "SCISSORS")
- {
- cin >> a;
- transform(a.begin(), a.end(), a.begin(), ::toupper);
- if (a != "ROCK" && a != "PAPER" && a != "SCISSORS") {
- cout << "YOU'RE CONFUSED AS WHAT TO DO WITH YOUR HAND." << endl;
- }
- }
- switch (r) {
- case 1:
- b = "ROCK";
- break;
- case 2:
- b = "PAPER";
- break;
- case 3:
- b = "SCISSORS";
- break;
- }
- cout << "\nTHE WORDS 'ROCK, PAPER, SCISSORS' ARE CALLED OUT!\nYOUR HAND REVEALS " << a << "." << "\nYOUR OPPONENT'S HAND REVEALS " << b << "." << endl;
- if (a == "ROCK") {
- if (b == "SCISSORS") { cout << "\nYOUR DECISION WAS A TRIUMPH! CONGRATS!" << endl; ws ++;}
- else if (b == "ROCK") { cout << "\nYOUR DECISION WAS A STALEMATE! OH BOY!" << endl; }
- else if (b == "PAPER") { cout << "\nYOUR DECISION WAS A FAILURE! TOO BAD!" << endl; ws = 0;}
- };
- if (a == "PAPER") {
- if (b == "ROCK") { cout << "\nYOUR DECISION WAS A TRIUMPH! CONGRATS!" << endl; ws ++;}
- else if (b == "PAPER") { cout << "\nYOUR DECISION WAS A STALEMATE! OH BOY!" << endl; }
- else if (b == "SCISSORS") { cout << "\nYOUR DECISION WAS A FAILURE! TOO BAD!" << endl; ws = 0;}
- };
- if (a == "SCISSORS") {
- if (b == "PAPER") { cout << "\nYOUR DECISION WAS A TRIUMPH! CONGRATS!" << endl; ws ++;}
- else if (b == "SCISSORS") { cout << "\nYOUR DECISION WAS A STALEMATE! OH BOY!" << endl; }
- else if (b == "ROCK") { cout << "\nYOUR DECISION WAS A FAILURE! TOO BAD!" << endl; ws = 0;}
- };
- cout << "\nYOUR WINNING STREAK IS: " << ws << endl;
- cout << "ANOTHER ROUND?" << endl;
- cin;
- system("pause");
- }
- }
Add Comment
Please, Sign In to add comment