Question: **In Java** - Dice are used in many games. One die can be thrown to randomly show a value from 1 through 6. Design a

**In Java** -

Dice are used in many games. One die can be thrown to randomly show a value from 1 through 6. Design a Die class that can hold an integer data field for a value (from 1 to 6). Include a constructor that randomly assigns a value to a die object. Also include a method in the class to return a dies value. Save the class as Die.java.

Write another class called TwoDice that uses the Die class to randomly throw two dice and displays their values and also determines the higher die.

Using the Die class, write another class called FiveDice that randomly throws five dice for the computer and five dice for the player. Display the values and then, decide who wins based on the following hierarchy of Die values. Any higher combination beats a lower one; for example, five of a kind beats four of a kind.

The hierarchy is-

Five of a kind

Four of a kind

Three of a kind

A pair

No two dice show the same number

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!