Question
Write a program to play the rock-paper-scissor game in Java code. Allow one user (player 1) to type in either P, R, or S. The
Write a program to play the rock-paper-scissor game in Java code. Allow one user (player 1) to type in either P, R, or S.
The program should also do the following:
Allow the user to enter lower-case as well as upper-case letters (you should convert to lower-case)
Use if, then, else statements to check for the winner:
Loop until player 1 or computer wins
Call method that will return computer's choice (see next major bullet)
Use typical game logic (rock breaks scissors, scissors cut paper, paper covers rock)
If the computer has selected the same value as player 1, announce a tie and continue loop
Identify player 1 or computer as winner and then break out of loop (use Boolean)
Use SecureRandom object to randomly pick the computers choice in the game
Declare and instantiate the object before main method (outside of main method so it is in scope for all methods)
Create a new method that will randomly pick Rock, Paper or Scissors (using SecureRandom object) and then return the result to main
Optional - Declare an enum that can be used for Rock, Paper or Scissors check -- declare the enum before main method (outside of main method so it is in scope for all methods)
--------------------------------------------------------------------------------------------
OKay, I first want to say thanks for helping me out. I have my psuedo code:
User types RPS Compare to computer Choice Loop Outside of main method make the Scanner for the Secure Random
But, I am unable to compare strings. I tried making them chars, but they wouldn't compare either. i tried changing them to numbers, but I couldn't get them to switch over. I"m really stuck and have been working on this for about 4 hours. Thanks!
--------------------------------------------------------------------------------------------
}
SecureRandom comupterChoice = new SecureRandom(); }
--------------------------------------------------------------------------------------------
So my problem is, I know
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started