CIS 501

Assignment Number 03p

Preliminary Assignment for:

DICE SIMULATION WITH ARRAYS AND CLASSES

Reading: Start reading as directed in the course Syllabus, Part C.

Programming: A small group project (groups of two students).

You will be writing a small program to simulate the rolling of a pair of dice until some number, n, of rolls has been completed OR until a 7 or 11 is rolled. The stopping condition should be the user's choice -- either some maximum number of rolls (such as 500 or 1000) or until some value (such as 7, 11, etc) is rolled.Also, if the loop repetition condition involves some maximum number of rolls, the user should be prompted for, and then enter, the maximum number of rolls involved (max = 1000).

Your program should keep track of the number of 2s, 3s, 4s, ... 12s rolled during the simulation. You should use an array of counters, where "counter" is a user-defined data type, for storing these counts.)At the completion of execution of the program, print the counts in a readable form.

For this preliminary assignment I just want you to do the following.

1.Write a counter class for a single value counter having a maximum value of 1000 and a minimum value of 0. You will have 3 data stores for your class, one to store the value and two others to store the maximum and minimum (constant) values for the class.

2.You will need just three functions in your class – a function to initialize your counter (to 0), one to increment your counter, and a third that simply returns the value of the counter when it is needed.These functions should each be VERY short.

3. Test your class with a simple test driver program that calls each of the three functions in the class, initializing the value once, incrementing the counter a few times, and then displaying the counter value.

Turn In:

1) A written description of the interface (and function prototypes) and data stores for the counter class.

2) A listing of a working counter class and test driver.

Due Date: To be determined.