Create an application that uses classes to roll a pair of six-sided dice. Create a class named Die to store the data about each die. This class should contain these constructors and methods: public...

Create an application that uses classes to roll a pair of six-sided dice.

  • Create a class named Die to store the data about each die. This class should contain these constructors and methods:

public Die() // set the initial value of the die to zeropublic void roll()public int getValue()

  • Create a class named Dice to store two dice. This class should contain two instance variables of the Die type and these constructors and methods:

public Dice() // instantiate the Die instance variablespublic int getDie1Value ()public int getDie2Value ()public int getSum() // get the sum of both dicepublic void roll() // roll both dicepublic void printRoll() // display result of roll

  • You can use the random method of the Math class to generate a random number for a die.

  • When printing the results of the roll of the dice, display the value of each die and the total. In addition, display special messages for craps (sum of both dice is 7), snake eyes (double 1’s), and box cars (double 6’s).

  • Continue only if the user enters “y” or “Y” at the “Roll again?” prompt.



Oct 07, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here