Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-Write aDieclass having a single int property that represents the current face value of the die. Have arollmethod that again uses the Math.random() method to

-Write aDieclass having a singleintproperty that represents the current face value of the die. Have arollmethod that again uses the Math.random() method to generate a new value for the die and also returns it. Have agetFaceValue()method to return the current face value of the die. Test this class by writing aTestDieclass with a main method that creates aDieobject and calls its methods. Modify it so that it creates and tests twoDieobjects. Add atoString()method to your class.

-Implement and test aDiceclass that uses twoDieobjects. Provide a method torollboth die together and return the result (a value between 2 and 12 inclusive), as well asgetDie1FaceValue(),getDie2FaceValue(),getDiceTotal()andtoString()methods.

-Using an instance of yourDiceclass, implement the same game as in part (1) above. Write aDiceGameclass whose only property is the dice and whose only method isplay(). This method should return the number of times the dice had to be rolled before a double six occurred. Write aTestDiceGameclass that has a main method that creates an instance of theDiceGameclass and calls itsplaymethod then prints the result.

Can you please send me the java codes for this homework?

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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions