Question: in java Create a class named Die to store the data about each die. This class should contain these constructors and methods: public Die() set
in java
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 zero public 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 variables public int getDie1Value () public int getDie2Value () public int getSum() get the sum of both dice public void roll() roll both dice public void printRoll() display result of roll
You can use the random method of the Math class to generate a random number for a die like this: value = (int) (Math.random() * 6) + 1;
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 1s), and box cars (double 6s).
Continue only if the user enters y or Y at the Roll again? prompt.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
