Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java write a program with the following criteria: Dice are used in many games. One die can be thrown to randomly show a value

In java write a program with the following criteria:

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago