Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using java Write a class Die which has members & methods: int sides : # of sides for the die int value : value of

using java

Write a class Die which has members & methods:

int sides: # of sides for the die

int value: value of the die

String owner: Name of player holding the die

Methods:

Appropriate constructors.

Set/get for sides, value and owner.

roll(): creates a random object and uses it to set value to a random number.

Write a main method that has the computer play against the user.

Ask the user for their name. Create a die for the user and one for the computer.

Ask the user how many sides they want the die to have.

Ask the user how many iterations they want to play with.

Create a loop that runs for the iterations specified by the user. In each iteration roll both die and check

which one has a larger value. The die with the larger value gets a point. In case of a tie, no one gets a

point. At the end, print the score and the name of the winner.

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

More Books

Students also viewed these Databases questions

Question

b. Did you suppress any of your anger? Explain.

Answered: 1 week ago

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago