Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. You entered: paper
  2.  
  3. public static Scanner kbd;
  4.  
  5. public static void main(String[] args) {
  6.  
  7. kbd = new Scanner(System.in);
  8.  
  9. //Variable Declaration.
  10.  
  11. String Answer;
  12.  
  13. System.out.println("The Game of Paper, Rock, Scissors");
  14.  
  15. System.out.print("n" + "Do you need instructions (Y or N)? ");
  16. Answer = kbd.next().toUpperCase();
  17.  
  18. if (Answer.contentEquals("Y")) {
  19.  
  20. //Instructions method.
  21. instructions();
  22. }
  23. playGames();
  24.  
  25. }//End of Public static Main.__________________
  26.  
  27. /**
  28. *This method allows the user to request instructions prior to
  29. *game starting.
  30. *
  31. */
  32.  
  33. public static void instructions() {
  34.  
  35. System.out.print("n" + "This is the popular game of paper, rock, scissor. Enter your choice by typing the word "paper""
  36. + ", the word "rock" or the word "scissors". nThe computer will also make a choice from the three options. "
  37. + "After you have entered your choice, the winner of the ngame will be determined according to the following rules: " + "n");
  38.  
  39. System.out.println("n" + "Paper wraps rock (paper wins)"
  40. + "nRock beats scissors (rock wins) nScissors cuts paper (scissors wins)n nIf both you and the computer enter the same choice,"
  41. + "the game is tied.");
  42.  
  43. }//End of Public static instructions. _____________
  44.  
  45. /**
  46. *This method calculates the user's choice against the computer's random
  47. *select to collect a win and a tie back to the user. The results will be used
  48. *for tracking games played, wins for user vs wins for computer and tied games.
  49. *
  50. */
  51.  
  52. public static void playGames() {
  53.  
  54. //Variable Declaration.
  55. String userInput, proceed;
  56.  
  57. int gamesPlayed;
  58.  
  59. gamesPlayed = 0;
  60.  
  61. //The PRS game functionality.
  62. do {
  63.  
  64. System.out.print("n" + "Enter your choice: ");
  65. userInput = kbd.next().toLowerCase();
  66.  
  67.  
  68.  
  69.  
  70.  
  71. System.out.print("n" + "Play again (Y or N)? ");
  72. proceed = kbd.next().toUpperCase();
  73.  
  74. gamesPlayed++;
  75. //kbd.close();
  76.  
  77. //if (proceed.contentEquals("Y")) {
  78.  
  79. //}
  80. }
  81. while (proceed.contentEquals("Y"));{
  82. kbd.close();
  83.  
  84. System.out.printf("n" + "Total number of games Played: " + gamesPlayed+ "n");
  85. System.out.printf("Total number of wins for player: "+ "n");
  86. System.out.printf("Total number of wins for me: " + "n");
  87. System.out.printf("Tied games: ");
  88. //System.out.printf("", );
  89.  
  90. }
  91.  
  92. }//End of public static playgames.
  93.  
  94. /**
  95. *
  96. * @return
  97. */
  98.  
  99. public static String computerChoose() {
  100.  
  101. //Variable Declaration.
  102. Random generator = new Random();
  103.  
  104. String [] answer = new String[3];
  105. answer[0] = "paper";
  106. answer[1] = "rock";
  107. answer[2] = "scissors";
  108.  
  109.  
  110. return answer[generator.nextInt(3)];
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement