Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- You entered: paper
- public static Scanner kbd;
- public static void main(String[] args) {
- kbd = new Scanner(System.in);
- //Variable Declaration.
- String Answer;
- System.out.println("The Game of Paper, Rock, Scissors");
- System.out.print("n" + "Do you need instructions (Y or N)? ");
- Answer = kbd.next().toUpperCase();
- if (Answer.contentEquals("Y")) {
- //Instructions method.
- instructions();
- }
- playGames();
- }//End of Public static Main.__________________
- /**
- *This method allows the user to request instructions prior to
- *game starting.
- *
- */
- public static void instructions() {
- System.out.print("n" + "This is the popular game of paper, rock, scissor. Enter your choice by typing the word "paper""
- + ", the word "rock" or the word "scissors". nThe computer will also make a choice from the three options. "
- + "After you have entered your choice, the winner of the ngame will be determined according to the following rules: " + "n");
- System.out.println("n" + "Paper wraps rock (paper wins)"
- + "nRock beats scissors (rock wins) nScissors cuts paper (scissors wins)n nIf both you and the computer enter the same choice,"
- + "the game is tied.");
- }//End of Public static instructions. _____________
- /**
- *This method calculates the user's choice against the computer's random
- *select to collect a win and a tie back to the user. The results will be used
- *for tracking games played, wins for user vs wins for computer and tied games.
- *
- */
- public static void playGames() {
- //Variable Declaration.
- String userInput, proceed;
- int gamesPlayed;
- gamesPlayed = 0;
- //The PRS game functionality.
- do {
- System.out.print("n" + "Enter your choice: ");
- userInput = kbd.next().toLowerCase();
- System.out.print("n" + "Play again (Y or N)? ");
- proceed = kbd.next().toUpperCase();
- gamesPlayed++;
- //kbd.close();
- //if (proceed.contentEquals("Y")) {
- //}
- }
- while (proceed.contentEquals("Y"));{
- kbd.close();
- System.out.printf("n" + "Total number of games Played: " + gamesPlayed+ "n");
- System.out.printf("Total number of wins for player: "+ "n");
- System.out.printf("Total number of wins for me: " + "n");
- System.out.printf("Tied games: ");
- //System.out.printf("", );
- }
- }//End of public static playgames.
- /**
- *
- * @return
- */
- public static String computerChoose() {
- //Variable Declaration.
- Random generator = new Random();
- String [] answer = new String[3];
- answer[0] = "paper";
- answer[1] = "rock";
- answer[2] = "scissors";
- return answer[generator.nextInt(3)];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement