Question: Create a class named Dice to store data about each die. This class should contain these constructors and methods: public Dice() //default to 6 sided
Create a class named Dice to store data about each die. This class should contain these constructors and methods:
public Dice() //default to 6 sided die
public Dice(int sides) //allow a variable number of sides
public void roll()
public int getValue()
Use the random method of the Math class to generate a random number from 1 to the number of sides on a die. You need to use javadoc comments to provide a description for each method.
Then, write a tester program that will roll two objects of the dice class 20 times for each one and count how many times the number 6 appears. Then it printout the results.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
