Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There is a game that some children play called rock-scissors-paper. Two contestants each select one of the items: rock, scissors or paper, make a symbol

image text in transcribed
There is a game that some children play called rock-scissors-paper. Two contestants each select one of the items: rock, scissors or paper, make a symbol with their hands representing this object and then the two contestants simultaneously show their representation of the object to the other. The winner is decided as follows: Rock beats scissors.. Scissors beats paper. Paper beats rock Combinations of similar objects are considered a draw simulate two people playing this game by writing a program in Java that uses threads. Each player is to be represented by a thread; the same instance of each thread must be used for all "rounds" (see next item). Let the playing of the game by the two players be called a round The code is to simulate the playing of n-rounds of the game. For each round the values selected by the two players are to be compared; that is, the values selected by each player in a given round are to be compared -not values from different rounds. This comparison is to be performed as the values are generated. It is not acceptable to store the values in arrays and perform the comparisons at a later.time You must use the following Java keywords to help synchroaize your program: synchronized, wait, notify (or notifyAll in place of notify). Run your program for the processing of at least 1000 rounds. Display summary statistics to show that the program worked correctly. See the sample Sample output Round 997: Player 1 wins! Round 998: Player 1 selects rock Round 997: Player 2 loses Round 998: Player 2 selects scissors Round 998: Player 2 loses Round 999: Player 2 selects scissors Round 998: Player 1 wins! Round 999: Player 1 selects scissors Round 999: Player 1: Draw Round 999: Player 2: Draw Summary Statistics: Number of draws: 343 Number of times scissors won: 235 Number of times rock won: 310 Number of times paper won: 112 words D English Inited Stat

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago