Guest User

Untitled

a guest
Oct 23rd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. package motoVehicle;
  2.  
  3. import java.util.*;
  4.  
  5. public class RockPaperScissors {
  6. final static int ROCK = 1, PAPER = 2 , SCISSOR = 3;
  7. public static void main(String[] args)
  8. {
  9. Scanner scan = new Scanner(System.in);
  10.  
  11. int score = 0, score2 = 0;
  12.  
  13. System.out.println("Player One: Choose your weapon!");
  14. int player1 = scan.nextInt();
  15. System.out.println("Good choice!");
  16.  
  17. System.out.println( "Player Two: Choose your weapon!");
  18. int player2 = scan.nextInt();
  19. System.out.println("Good choice!");
  20.  
  21. do {
  22.  
  23.  
  24. switch (player1) {
  25. case ROCK:
  26. if (player2 == ROCK) {
  27. System.out.println("Player One chose: rock");
  28. System.out.println("Player Two chose: rock");
  29. System.out.println("It’s a draw!");
  30. System.out.println("The score is now: " + score + " - " + score2);
  31. }
  32. else if (player2 == SCISSOR) {
  33. System.out.println("Player One chose: rock");
  34. System.out.println("Player One chose: scissor");
  35.  
  36. System.out.println();
  37. System.out.println("Player One Wins");
  38. score++;
  39. System.out.println("The score is now: " + score + " - " + score2 );
  40. } else {
  41. System.out.println("Player One chose: rock");
  42. System.out.println("Player Two chose: paper");
  43. System.out.println();
  44. System.out.println("Player Two Wins");
  45. score2++;
  46. System.out.println("The score is now: " + score + " - " + score2 );
  47. }
  48. break;
  49.  
  50. case PAPER:
  51. if (player2 == PAPER) {
  52. System.out.println("Player One chose: paper");
  53. System.out.println("Player Two chose: paper");
  54. System.out.println("It’s a draw!");
  55. System.out.println("The score is now: " + score + " - " + score2);
  56. }
  57.  
  58.  
  59. else if (player2 == ROCK) {
  60. System.out.println("Player One chose: paper");
  61. System.out.println("Player Two chose: rock");
  62. System.out.println();
  63. System.out.println("Player One Wins");
  64. score++;
  65. System.out.println("The score is now: " + score + " - " + score2 );
  66. } else if (player2== SCISSOR) {
  67.  
  68. System.out.println("Player One chose: paper");
  69. System.out.println("Player Two chose: scissor");
  70. System.out.println();
  71. System.out.println("Player Two Wins");
  72. score2++;
  73. System.out.println("The score is now: " + score + " - " + score2);
  74. }
  75. break;
  76. case SCISSOR:
  77. if (player2 == SCISSOR) {
  78. System.out.println("Player One chose: scissor");
  79. System.out.println("Player Two chose: scissor");
  80. System.out.println("It’s a draw!");
  81. System.out.println("The score is now: " + score + " - " + score2);
  82. }
  83.  
  84. else if (player2 == PAPER) {
  85. System.out.print("Player One chose: scissors");
  86. System.out.print("Player One chose: paper");
  87. System.out.println();
  88. System.out.println("Player One Wins");
  89. score++;
  90. System.out.println("The score is now: " + score + " - " + score2 );
  91. } else {
  92. System.out.println("Player one chose: scissor");
  93. System.out.println("Player two chose: rock");
  94.  
  95. System.out.println();
  96. System.out.println("Player Two Wins");
  97. score2++;
  98. System.out.println("The score is now: " + score + " - " + score2);
  99. }
  100. break;
  101. case 4:
  102. if(player2 == player2){
  103. System.out.println("player One and Player Two are tied with " + score + "points.");
  104. }else if (player1 > player2) {
  105. System.out.println("The winner is Player One with " + score + "points.");
  106. }else {
  107. System.out.println("The winner is Player Two with " + score2 + "points.");
  108. System.out.println("Quitting.");
  109. }
  110. }
  111.  
  112.  
  113.  
  114. System.out.println("Player One: Choose your weapon!");
  115. player1 = scan.nextInt();
  116.  
  117.  
  118. if (player1!=4){
  119. System.out.println("Good choice!");
  120. System.out.println( "Player Two: Choose your weapon!");
  121. player2 = scan.nextInt();
  122. System.out.println("Good choice!");
  123.  
  124. }else
  125. if(score == score2){
  126. System.out.println("player One and Player Two are tied with " + score + " points.");
  127. System.out.println("Quitting.");
  128. }else if (score > score2) {
  129. System.out.println("The winner is Player One with " + score + " points.");
  130. System.out.println("Quitting");
  131. }else if (score < score2) {
  132. System.out.println("The winner is Player Two with " + score2 + " points.");
  133. System.out.println("Quitting.");
  134. }
  135. } while ((player1 == 1) || (player1 == 2) || (player1 == 3) ) ;
  136.  
  137. }
  138.  
  139. }
Add Comment
Please, Sign In to add comment