Question: should have a public getter method for each instance variable and each static variable Write a class TestDice with a main method that will do

should have a public getter method for each instance variable and each static variable Write a class TestDice with a main method that will do the following SidedDie object representing a 4-sided die, rolls it twenty times, and displays each of the twenty rolls, the total of the twenty rolls, and the average of the twenty rolls on a single line. Do the same for objects representing a 6-sided, 8-sided die, a 12-sided die, and a 20-sided die. Determine the number of N SidedDie objects that have been created by calling the appropriate getter method and displaying the result (which should be S). Run the TestDice class and check that the output seems reasonable 0. (10 pts) Write a class called CollectionOfDice with private instance variables numberOfDice (an integer) and diceArray which is a reference to an array of [references to) N SidedDie objects. (You may wish to refer to section 9.11 Array of Objects in the textbook.) 3. 1. CollectionofDice should have a no-argument constructor which initialzes its instance variables to represent a collection" of just one six-sided die CollectionofDice should have a two-argument constructor with parameters numberOfDice and numberOfSides which initialzes its instance variables to represent a collection of numberOfDice dice each of which has numberOfSides sides For example, a call to CollectionOfDicet 3, 6) would create a collection of three six-sided dice. CollectionofDice should have a public rollDicel) method which calls the rollDie() method of each N_SidedDie object referred to by diceArray and returns the total value of all the dice rolls

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 Databases Questions!