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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started