Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Dice are used in many games. One die can be thrown to randomly show a value from 1 through 6 . Design a Die class
Dice are used in many games. One die can be thrown to randomly show a value from through Design a Die class that can hold an integer data field for a value from to Include a constructor that randomly assigns a value to a die object. For example, the following statement generates a random number between LOWESTDIEVALUE which should contain the value and HIGHESTDIEVALUE which should contain the value and assigns it to a variable.
randomValue intMathrandom HIGHESTDIEVALUE LOWESTDIEVALUE;
Also include a method in the class to return a Die's value. Save the class as Die.java. Write an application that randomly "throws" two dice and displays their values. Save the application as TwoDice.java.
Using the Die class, write an application that randomly "throws" five dice for the computer and five dice for the player. Display the values and then, by observing the results, decide who wins based on the following hierarchy of Die values. The computer will not decide the winner; the player will determine the winner based on observation. Later, you will learn to program the determination of the winner. Any higher combination beats a lower one; for example, five of a kind beats four of a kind.
Five of a kind
Four of a kind
Three of a kind
A pair
After you learn about decision making, you will be able to make the program determine whether you or the computer had the better roll. For now, just observe how the values change as you execute the program multiple times. Save the application as FiveDice.java.
Create a zip file of the java files and submit the assignment.
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