Question: a java application need to create a multi-threaded application with one thread being a producer of playing cards and another thread being a consumer of

a java application need to create a multi-threaded application with one thread being a producer of playing cards and another thread being a consumer of playing cards.

The buffer will be based on the SynchronizedBuffer but will store a Card instead of an int.

The producer will produce a playing card having a random value of either 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, or Ace. The producer will put that randomly created card in the buffer. Afterward, the producer will sleep randomly between 1-4 seconds before producing another card.

The consumer will get 2 cards from the buffer. Once the consumer has 2 cards, it will use them to simulate the card game WAR. The consumer will compare the cards and print the winner. Afterward, the consumer will sleep randomly between 1-4 seconds before consuming cards and simulating the game again.

Both producer and consumer will run forever. This means the output of the game will never end the game will play forever.

Watch a demonstration of the application:

https://youtu.be/MDpKPx0FBcc

All classes must be in a package following these rules:

The package name is your last name plus the first letter of your first name. For example, if you name is Rita Red, her package is red.r

Package names are all lowercase letters

All class names must start with an UPPERCASE letter then camel-cased after that.

All property names must start with a lowercase letter then came-cased after that.

All method names must start with a lowercase letter then came-cased after that.

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!