Question: Using Java, write a method that will be used in the upcoming interface-based CCC (competitive coding contest). Write and test the method //0 = rock,

Using Java, write a method that will be used in the upcoming interface-based CCC (competitive coding contest).
Write and test the method
//0 = rock, 1 = paper, 2 = scissors, 3 = lizard, 4 = Spock
public static int judgeRPSLS(int player1move, int player2move)
This method should take the choices made by two players of Rock-Paper-Scissors-Lizard-Spock and return an int indicating which player won:
Return 1 if player 1 wins
Return 2 if player 2 wins
Return 0 if it's a tie
No value other than 0, 1, or 2 may be returned. The values of the arguments code for the move, as listed above:
0 = rock
1 = paper
2 = scissors
3 = lizard
4 = Spock
If either argument is outside of the range [0, 4], your method should throw an IllegalArgumentException.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!