CS12, Lab 2

Lab Cycle of April 12-16

 

 

Topics:          

·       Defining a user-defined type

·       Assembling a project with multiple files

·       Classes that contain other user-defined classes        

·       Proper use of #include statements

 

 

In this lab you will be using the Dice class from lab 1 to create a new class, GameDice.

A GameDice object is composed of two six-sided Dice objects, and its most useful method rolls both Dice objects and outputs (cout) the roll onto the output stream. 

 

To do: 

·       Copy the files dice.h and dice.cpp, which contain the Dice class.

·       Create gameDice.h and gameDice.cpp that contain the following:

o      Two private Dice objects

o      A constructor, which takes no parameters

o      A destructor that outputs a message

o      A roll() method that rolls both Dice objects and outputs the result in the format                         

#, #  (where # represents a number).  Each roll should print on a separate line.

·       Create main.cpp that contains a short program that declares a GameDice object and rolls it six times.