Write program that plays Rock/Paper/Scissors with the computer. a) Write enumeration called HandSign that has 3 constants
Question:
Write program that plays Rock/Paper/Scissors with the computer.
a)Write enumeration called HandSign that has 3 constants for ROCK, PAPER, and SCISSORS. Each constant should be associated with a String value for display purposes (e.g. ROCK would be "Rock").
Include the standard items like a field and for the display name, and a constructor.
Add the following additional methods:
getRandomSign(): this method is static. It generates and returns one of the three random HandSign enums.
compareSign(HandSign other): this is a non-static method that comapres "this" hand sign with another hand sign. The value returned is a 0 (tie), 1 (this hand sign wins over the other hand sign), or a -1 (this hand sign loses over the other hand sign). This code doesn't have to be complicated - check for a tie first, thyen you can use a switch statement to test this hand sign and use conditionals in each case to determine if it's a win or a loss. For example: case ROCK: return (other == SCISSORS) ? 1 : -1; (if this hand sign is rock, return 1 (win) if other hand sign is scissors, otherwise, return -1 (loss)).
b)Fill in the code below to play Rock/Paper/Scissors: