Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Enhance the FiveDice class so that it stores the randomly thrown dice in an array of Die objects. Display the results for both the player
Enhance the FiveDice class so that it stores the randomly thrown dice in an array of Die objects. Display the results for both the player and computer for each round.
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. Appendix D contains information on generating random numbers. To fully under- stand the process, you must learn more about Java classes and methods. However, for now, you can copy the following statement to generate a random number between 1 and 6 and assign it to a variable. Using this statement assumes you have assigned appropriate values to the static constants. randomVa1ue = ((int) (Math. randon() * 100) % HIGHEST, DIE-VALUE + LOWEST_DIE VALUE); 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. After you read the chapter "Making Decisions," you will be able to have the game determine the higher die. For now, just observe how the values change as you execute the program multiple times. Save the application as TwoDice.javaStep 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