Assignment 4
Assignment 4
Dice Collection
Learning Objectives
This assignment is about creating and using arrays of objects.
The Assignment
You will define two classes – one to represent a die with an
arbitrary number of sides, and one to represent a collection of dice
(these are the model classes). Then you will roll the entire collection
repeatedly and use an array to build a histogram of the results. The
view class for this assignment uses a main method and Standard
Input and Output.
A DiceCollection object holds a set of Die objects in an array. The number of sides on each Die is
specified by passing an array of integers to the DiceCollection constructor. This array is used to create
and store the corresponding Die objects. A DiceCollection object can report the current sum of all the
sides showing on the dice, it can report the maximum and minimum possible sums, and it can roll all the
dice at once. It has a toString() method that reports all the dice, the minimum possible roll, the
maximum possible roll, and the current total showing on the dice. It also has a histogram method,
described below. That’s all it can do.
If they choose to roll once, show the result by printing the dice they got and the sum. If choose 100,000
rolls, call the histogram method described above, and print the non-zero elements of the array, as
shown in the example output.
Documentation Standards
Don’t forget to follow the Documentation Standards for the course (i.e. Javadoc comments, meaningful
variable and class names, consistent indenting). See the Documentation Standards on Canvas.
Please see Canvas for the instructions on due date and time and how to how to submit your work.
Evaluation
Your assignment will be evaluated for performance (20%), class diagram (20%), structure (40%), and
documentation (20%) using the rubric in the drop box.
Example Output
Below is an example output of the program. User input is boldfaced and red. You are free to make your
interface look however you like.
Dice Collection: d4=1 d4=3 d4=1 d6=4 Optional Extra 2: How about
Min=4 Max=18 Current=9 displaying the histogram as a
bar graph using the
1=roll once, 2=roll 100000 times, 3=quit: 3 FXAnimationTemplate?
BYE!!!