Assignment Number 07-F2001
DICE SIMULATION WITH ARRAYS AND CLASSES
Reading: Finish reading as directed in the CIS 067 Syllabus, Section F.
Programming: 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. PLEASE -- no more than 1000 rolls.
Your program should keep track of the number of 2s, 3s, 4s, ... 12s rolled during the simulation. (To put it another way you will keep track of the frequency of occurrence of 2s, 3s, 4s, 12s). You should use an array of counters, where each counter is a user-defined data type (of type counter_type), for storing these counts. At the completion of execution of the program, print the counts in a readable form.
You should also include in your program a highly user-friendly interface which welcomes the user by first asking for his or her name and then printing out a welcome message that includes the name. You then should ask the user to indicate whether a fixed number of rolls is involved and if so, request this number of rolls from the user. You should consider writing this interface as a separate class (named user_interface_type).
In addition to the counter and interface classes, your program should include a dice_type class which manages the rolling of the dice and returns a value between 2 and 12. This class might contain only one public function -- for rolling the dice. This function will use the C library's random number generator function to obtain a valid roll of the dice (between 2 and 12). You will need to look up the functions random and srand, and you will probably also find it useful to use the time function as well. The use of these functions will be explained in lab.
Turn In (all to the lab assistant):
NOTE: You will need to find out how to access the random number seed and random number generator function for your version of C. These should be named srand and random (or something similar) respectively. You may work in groups of no more than 2 people.
