Two dice
Class diagram for problem 2a
Class diagram for problem 2a with details and visibility

ICT-4361 Homework 2a


The purpose of this exercise is to develop a very simple class that we will use in a number of future exercises

What to Hand In

For this, as well as future programming exercises, hand in a listing of the program (which must be formatted in a reasonable style), and sample run(s) of the program.

Remember to use our Java naming conventions!

Canvas submission instructions:
Please combine multiple files into a single "zip" archive, and save it in a location that you will remember. When you are ready to submit the assignment, open that assignment, and submit your file as the assignment solution.

Please pay attention to your code indentation to ensure your paper is easy to read and understand.


  1. It's Dicey
    1. Create a class called Dice to represent a single cube. The class diagram for class is shown. There may be many Dice objects, and each is responsible for remembering and reporting (on request) its current value (that is, the number showing), using its numberShowing property. The Dice object also requires a method called roll() that randomly selects a number from 1 to 6 for the value of the dice, and remembers it.
    2. Create a test main method for the Dice class that creates a Dice, and rolls it many times.
  2. Can you keep track of how many times each number (1,2,3,4,5, or 6) comes up? Describe how in a three or fewer sentences, or implement it in your program.
  3. Describe which number comes up (or is expected to come up) the most often in a sentence. Back your answer up with your statistics if possible. If your program rolls a Dice object, please ensure it is rolled at least 1,000 times.



Criteria Weight
Creation of a Dice class with a numberShowing int data member, and its "getter". 20%
Creation of a Dice class object of type Random, with the variable name randomNumber, for use in the roll() method. 20%
Creation of a roll() member function, using the randomNumber object, which returns an appropriate int 20%
Keeping track of how many times each number comes up: paragraph or code 20%
Answering (in a comment, output, or text document) which number is most common? Sentence or statistics 10%
Captured output 10%