Question: Part A For this part you will create a die ( 6 faces ) class which have those specifications below. The classname will be Die

Part A
For this part you will create a die (6 faces) class which have those specifications below. The
classname will be Die
Die class will have a no argument constructor which will initialize faceValue to 1.
Die class will hold private faceValue with integer type as an instance variable.
You will write a method to get the faceValue of the Die.
You will also write a void setFaceValue method to set the faceValue of the die using the method
arguement which will be an integer.
Die class will have a void roll method. This method will roll the die randomly, creating a number
between 1 to 6, both inclusive. In other words, it will change the faceValue randomly. This method
will not print anything.
Part B
For this part you will create a Dice class which holds 2 private Die objects as instance variables.
Die class will have a no argument constructor which will initialize faceValues of the both dies to
1.
You will write a method to get the faceValue of the Dice which is the sum of the faceValues of the
2 dice.
Die class will have a void roll method. This method will roll both Dice. This method will not print
anything.
Part C
For this part you will create a DiceTester class which will do the following:
(name of this class will be your lastname firstname.java)
DiceTester will have the main method inside. The other classes won't have any main method inside.
You will roll the dice 1000 times. After each roll, you will store number of occurrences of the
faceValues in an integer array.
Then you will print those values starting from 2 until 12 after rolling the Dice 1000 times.
You will also draw a histogram graph shown below. They y axis will start from 175 and decrease
by 25 until 0.
Please take note of the spaces on x axis numbers. If the x axis number has one digit there are 2
spaces. If the x axis number has 2 digits there is one space between them.
Part A For this part you will create a die ( 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!