Question: Write a class Die which has members & methods: int sides : # of sides for the die int value : value of the die

Write a class Die which has members & methods:

int sides: # of sides for the die

int value: value of the die

String owner: Name of player holding the die

Methods:

Appropriate constructors.

Set/get for sides, value and owner.

roll(): creates a random object and uses it to set value to a random number.

Write a main method that has the computer play against the user.

Ask the user for their name. Create a die for the user and one for the computer.

Ask the user how many sides they want the die to have.

Ask the user how many iterations they want to play with.

Create a loop that runs for the iterations specified by the user. In each iteration roll both die and check

which one has a larger value. The die with the larger value gets a point. In case of a tie, no one gets a

point. At the end, print the score and the name of the winner.

NO import java.util.concurrent.TimeUnit;

CODE IN JAVA

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!