Question: iN JAVA LANGUAGE PLEASE Problem: design and implement an application that plays Rock-Paper-Scissors game against the computer. When played between two people, each person picks
iN JAVA LANGUAGE PLEASE
Problem: design and implement an application that plays Rock-Paper-Scissors game against the computer. When played between two people, each person picks one of the three options at the same time, and the winner is determined. The program should randomly choose one of the three options, then prompt for the users selection. At that point, the program reveals both choices and print a statement indicating if the user won, the computer won, or if it was a tie. Continue playing until the user choose to stop., then print the total number of the games played, total wins, total losses, and total ties.
Requirements:
Proper naming
Indentation
Using methods
Main method can only have couple lines of codes.
You must generate the exact same output
No use of constants
You must have all the methods listed below to get the credit for this lab.
Here is the list of the tasks that needs to be done using methods:
A method that outputs the description and rules of the game
A method to generate a random number for the computer selection: This method should get a
Random object as its parameter. This method must generate a random 0 or 1 or 2. Your method should return rock, paper or scissors based on the random number that was generated. You must use case statements not if statements. This method returns a string
A method to get the users choice: this method gets a Scanner object as its parameter. This methods gets the user input and returns it. You must validate the users input, meaning that anything other than rock, paper, and scissors or stop is not a valid input. Keep prompting the user until you get a valid input. Once you have the valid input, return it
A method called play that actually plays the game. This method will allow the user to keep playing by using a while loop. This method should call other methods to get the game started. Call the other methods to get the users choice and computer choice,. You need a lot of conditions statements to decide whether the user won or not. In this method you keep track of the wins, losses, and ties. Once the users input is stop, then display the result for the game.
In the main method call the method play. There should be a while loop in the main to allow playing the game again.
Here is a sample output:
Using this app you can play Rock-Paper-Scissors game against the computer. When played between two people, each person picks one of the three options at the same time, and the winner Is determined. The program should randomly choose one of the three options, then prompt for the users selection. At that point, the program reveals both choices and print a
Statement indicating if the user won, the computer won, or if it was a tie. Continue playing until the user choose to stop. Then print the total number of the games played, total wins, total losses, and total ties.
Ready, Set, Go
your choices Rock
Paper Scissors stop
Enter your choice: roCk
Computer selected: rock You selected : ROCK
There is a tie your choices Rock
Paper Scissors stop
Enter your choice: paper
Computer selected: Scissors You selected : PAPER
Oh No, you lost your choices Rock
Paper Scissors stop
Enter your choice: scissors
Computer selected: rock You selected : SCISSORS
Oh No, you lost
your choices Rock
Paper Scissors stop
Enter your choice: rock
Computer selected: Scissors You selected : ROCK
Hurray! You won.
your choices Rock
Paper Scissors stop
Enter your choice: PapeR
Computer selected: Paper You selected : PAPER
There is a tie your choices Rock
Paper Scissors stop
Enter your choice: papers your choices
Rock Paper Scissors stop
Enter your choice: rocks your choices
Rock Paper Scissors stop
Enter your choice: stop ------------------------------------ Here is the result of the play: Times played: 5 Wins: 1 Losses: 2 Ties : 2 Sorry computer won this time. Try again
---------------------------------- Do you want to play again? Yes
Using this app you can play Rock-Paper-Scissors game against the computer. When played between two people, each person picks one of the three options at the same time, and the winner Is determined. The program should randomly choose one of the three options, then prompt for the users selection. At that point, the program reveals both choices and print a
Statement indicating if the user won, the computer won, or if it was a tie. Continue playing until the user choose to stop. Then print the total number of the games played, total wins, total losses, and total ties. Ready ,Set, Go
your choices Rock
Paper Scissors stop
Enter your choice: rock
Computer selected: rock You selected : ROCK
There is a tie your choices Rock
Paper Scissors stop
Enter your choice: paPER
Computer selected: Paper You selected : PAPER
There is a tie your choices Rock
Paper Scissors stop
Enter your choice: scissors
Computer selected: Paper You selected : SCISSORS
Hurray!! you won.
your choices Rock
Paper Scissors stop
Enter your choice: paper
Computer selected: Paper You selected : PAPER
There is a tie your choices
Rock Paper Scissors stop
Enter your choice: rock
Computer selected: Scissors You selected : ROCK
Hurray! You won.
your choices Rock
Paper Scissors stop
Enter your choice: ssdsd your choices
Rock Paper Scissors stop
Enter your choice: sdfsfd your choices
Rock Paper Scissors stop
Enter your choice: sdf your choices
Rock Paper Scissors stop
Enter your choice: rocks your choices
Rock Paper Scissors stop
Enter your choice: paper
Computer selected: rock You selected : PAPER
Hurray!! you won. your choices
Rock Paper Scissors stop
Enter your choice: stop ------------------------------------ Here is the result of the play: Times played: 6 Wins: 3 Losses: 0 Ties : 3 Congratulations! You won.
---------------------------------- Do you want to play again? No GOOD BYE. COME BACK SOON
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
