Question: Pleased write a program that allows your computer program play the rock-paper-scissors-lizard-spock game against itself. Refer to http://en.wikipedia.org/wiki/Rock-paper-scissors-lizard-Spock for more information.
In this problem, the program simulates two players who play against each other. The play continues until one of the computer-generated players wins 4 times. Solve the problem using a class called “RockPaperScissorLizardSpock”. Feel free to use as many other classes as needed to make proper use of OOP design.
The program should use multiple threads to simulate “simultaneous play”, just as in the real game itself. Use multi-threading / concurrency techniques to simulate the actual game’s simultaneous play method where both players throw their hand at the same time for each iteration of the game and then determine who wins this play.
In this game, in every iteration, two random integers are generated in the range of [1 to 5] – 1 refers to Rock. 2 refers to Paper. 3 refers to Scissors. 4 refers to Lizard. 5 refers to Spock.
For example, if the computer randomly generates integers 2 and 5 in the first iteration, 2 is for the first player and 5 is for the second player. 2 refers to Paper and 5 refers to Spock. Based on Rule 8 in the following 10 rules, Paper (2) disproves Spock (5), so player 1 wins.
Likewise, continue the iterations until one player wins 4 times. All other outcomes such as the “Spock vs. Spock” would be considered a draw. Also, ensure that the play ends after a certain number of iterations. Use custom Exceptions with try/catch and not accept any system error message.
rule 1: Scissor cut paper
rule 2: Paper covers rock
rule 3: Rock crushes lizard
rule 4: Lizard poisons Spock
rule 5: Spock smashes (or melts) scissor
rule 6: Scissor decapitate lizard
rule 7: Lizard eats paper
rule 8: Paper disproves Spock
rule 9: Spock vaporizes rock
rule 10: Rock breaks scissors