Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the program below as the Driver program to test your Class Die. Develop a Java Class Die that will manage a roll of a

image text in transcribed

Use the program below as the Driver program to test your Class Die.

image text in transcribed

Develop a Java Class Die that will manage a roll of a six-sided die. Once you develop the Class Die, use the Driver program given at the bottom to test your Class Die. The Class Die that you create will include a separate method to perform each of the following: 1. 2. 3. 4. Roll one die and return the value Return the sum of a pair of dice rolled. Roll a pair of dice and return a true if doubles has been rolled. Roll a pair of dice and return the face value if doubles has been rolled. . Include a Constructor for this class. The Constructor will not initialize any instance data so it will not contain any code. o On the chart below is a list of each method name, description, parameter arguments and data type of each parameter argument the method will need, and the return value and data type of the method. Public/Private Method Name Public Public Return Value and Data None Returns an integer from Description Parameters and Data T None Die () This is the constructor Rolls one die None with face value of1 to 6 roll() to Public sum(int first, int second) Calculates the Two integers sum of two representing the Returns an integer roll of a pair of ice. Public isDoubles(int first, int Determines if Two integers second) Returns a boolean value if face value of both die the face value of two dice is representing the of a pair of are equal ua Public faceValue(int first, int second) Gets face value if a doubles is rolled Two integers representing the roll of a pair of Returns the integer face value if doubles is rolled else returns a zero. It is extremely important that you correctly match the criteria for each method from the above chart. If you don't then your Class Die will not communicate with the driver. You must: Use the given names for each method. 2. Correctly match the parameter list for each method. Make sure that the number of parameters, order of parameters, and data type of each parameter is the same. 3. Make sure the return data type for each method is the same as listed in the chart above. 1. public class TestDie public static void main (String [] args) Local Constants final int MAXROLLS 1000; //Maximum number of rolls - /Local Variables int numl, num2: int total; boolean doubles; int numDoubles 0; number of doubles rolled int doubleValue /dice /lsum of a roll true if doubles has been rolled //face value if doubles has been rolled /Instantiate two Objects of the external Class Die Die diel new Die) create one die Object of Class Die Die die2 new Die create a second die Object of Class Die /Test the roll of one die numl-diel.roll) num2 die2.roll System.outprintin"You have rolled a"+num+"and a" num2); Test returning the sum of a roll of a pair of dice total diel.sum(numl, num2); System.outprintin"You have rolled a"+total) /Test for number of doubles rolled out of 1000 for( int numRolls 1; numRolls

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago