Advertisement
Guest User

Untitled

a guest
May 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. System.out.println("Hey, let's play Rock, Paper, Scissors!n" +
  2. "Please enter a move.n" + "Rock = R, Paper" +
  3. "= P, and Scissors = S.");
  4.  
  5. System.out.println();
  6.  
  7. //Generate computer's play (0,1,2)
  8. computerInt = generator.nextInt(3)+1;
  9.  
  10. //Translate computer's randomly generated play to
  11. //string using if //statements
  12.  
  13. if (computerInt == 1)
  14. computerPlay = "R";
  15. else if (computerInt == 2)
  16. computerPlay = "P";
  17. else if (computerInt == 3)
  18. computerPlay = "S";
  19.  
  20.  
  21.  
  22. //Get player's play from input-- note that this is
  23. // stored as a string
  24. System.out.println("Enter your play: ");
  25. personPlay = scan.next();
  26.  
  27. //Make player's play uppercase for ease of comparison
  28. personPlay = personPlay.toUpperCase();
  29.  
  30. //Print computer's play
  31. System.out.println("Computer play is: " + computerPlay);
  32.  
  33.  
  34.  
  35.  
  36. if (personPlay.equals(computerPlay))
  37. System.out.println("It's a tie!");
  38. else if (personPlay.equals("R"))
  39. if (computerPlay.equals("S"))
  40. System.out.println("Rock crushes scissors. You win!!");
  41. else if (computerPlay.equals("P"))
  42. System.out.println("Paper eats rock. You lose!!");
  43. else if (personPlay.equals("P"))
  44. if (computerPlay.equals("S"))
  45. System.out.println("Scissor cuts paper. You lose!!");
  46. else if (computerPlay.equals("R"))
  47. System.out.println("Paper eats rock. You win!!");
  48. else if (personPlay.equals("S"))
  49. if (computerPlay.equals("P"))
  50. System.out.println("Scissor cuts paper. You win!!");
  51. else if (computerPlay.equals("R"))
  52. System.out.println("Rock breaks scissors. You lose!!");
  53.  
  54. String answer = "Y";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement