http://www.du.edu/~mschwart/ICT4361/161px-Two_red_dice_01.svg.png
Two dice
http://www.du.edu/~mschwart/ICT4361/HW2Dice.png
Class diagram for problem 2a
http://www.du.edu/~mschwart/ICT4361/HW2Dice_detail.png
Class diagram for problem 2a with details and visibility

ICT-4361 Homework 2a

Purpose

The purpose of this exercise is to develop a very simple class that we will use in a number of future exercises. An important goal is to think in object-oriented terms.

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) (.java file or files), and sample run(s) of the program. Sample runs may be submitted as text files (.txt) or image files (.jpg, .png)

Remember to use our Java naming and coding 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.

Problems

  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 well-written sentences, or implement it in your program.
  3. Does one number comes up (or is expected to come up) significantly more often than the others? If so, which one? State your hypothesis about the frequency of each number 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. You could easily roll it 1,000,000 times.

Notes

Evaluation

CriteriaWeight
Placing all Java code in a non-default package5%
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 int20%
Keeping track of how many times each number comes up: paragraph or code15%
Answering (in a comment, output, or text document) hypothesis about number frequencies. Sentence or statistics10%
Captured output10%