Guest User

Untitled

a guest
Oct 15th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. //declartions
  11. srand (time(NULL));
  12. string a, b;
  13. int r, ws;
  14. ws = 0; //win streak
  15.  
  16. //game logic
  17. while (true) {
  18. cout << "\n" << endl;
  19. cout << "AS YOUR OPPONENT READYS HIS HAND YOU READY YOURS!\nROCK, PAPER OR SCISSORS?" << endl;
  20. a = ""; //input varible
  21. b = ""; //villians hand
  22. r = (rand() % 3) + 1;
  23.  
  24. while (a != "ROCK" && a != "PAPER" && a != "SCISSORS")
  25. {
  26. cin >> a;
  27. transform(a.begin(), a.end(), a.begin(), ::toupper);
  28. if (a != "ROCK" && a != "PAPER" && a != "SCISSORS") {
  29. cout << "YOU'RE CONFUSED AS WHAT TO DO WITH YOUR HAND." << endl;
  30. }
  31. }
  32.  
  33. switch (r) {
  34. case 1:
  35. b = "ROCK";
  36. break;
  37. case 2:
  38. b = "PAPER";
  39. break;
  40. case 3:
  41. b = "SCISSORS";
  42. break;
  43. }
  44.  
  45. cout << "\nTHE WORDS 'ROCK, PAPER, SCISSORS' ARE CALLED OUT!\nYOUR HAND REVEALS " << a << "." << "\nYOUR OPPONENT'S HAND REVEALS " << b << "." << endl;
  46.  
  47. if (a == "ROCK") {
  48. if (b == "SCISSORS") { cout << "\nYOUR DECISION WAS A TRIUMPH! CONGRATS!" << endl; ws ++;}
  49. else if (b == "ROCK") { cout << "\nYOUR DECISION WAS A STALEMATE! OH BOY!" << endl; }
  50. else if (b == "PAPER") { cout << "\nYOUR DECISION WAS A FAILURE! TOO BAD!" << endl; ws = 0;}
  51. };
  52. if (a == "PAPER") {
  53. if (b == "ROCK") { cout << "\nYOUR DECISION WAS A TRIUMPH! CONGRATS!" << endl; ws ++;}
  54. else if (b == "PAPER") { cout << "\nYOUR DECISION WAS A STALEMATE! OH BOY!" << endl; }
  55. else if (b == "SCISSORS") { cout << "\nYOUR DECISION WAS A FAILURE! TOO BAD!" << endl; ws = 0;}
  56. };
  57. if (a == "SCISSORS") {
  58. if (b == "PAPER") { cout << "\nYOUR DECISION WAS A TRIUMPH! CONGRATS!" << endl; ws ++;}
  59. else if (b == "SCISSORS") { cout << "\nYOUR DECISION WAS A STALEMATE! OH BOY!" << endl; }
  60. else if (b == "ROCK") { cout << "\nYOUR DECISION WAS A FAILURE! TOO BAD!" << endl; ws = 0;}
  61. };
  62.  
  63. cout << "\nYOUR WINNING STREAK IS: " << ws << endl;
  64. cout << "ANOTHER ROUND?" << endl;
  65.  
  66. cin;
  67. system("pause");
  68. }
  69. }
Add Comment
Please, Sign In to add comment