LAB:
STARTING THE
BALLOON
RACE
PROJECT
Last week, we developed a rough design for the following specification:
We identified two classes that would be useful in addition to the main function -- Balloon and Display -- and identified the data and behavior for which each should be responsible. The Lab Entrance Assignment for this lab was to write up a draft balloon.h file for me to review.
Constructing Colorful Balloons
Although we used strings to represent Fish colors, use the CMU Graphics Library* color class (note the lack of capitalization) for the private data member of Balloon, the Color function return type, and the parameter to the constructor (if you pass the color to the constructor). To construct a random color (either in main or the Balloon constructor), you will have something like one of the following:
color randomColor(r.RandInt(255), r.RandInt(255), r.RandInt(255));
or myColor = color(r.RandInt(255), r.RandInt(255), r.RandInt(255));
You will need to include the CMU graphics header file (see display.h or display.cpp) to be able to use the color class.
Displaying a Balloon.
HINT: You may wish to use the DrawCircle or DrawEllipse functions. To draw a circle, you provide the x- and y-coordinates of the center of the circle, the radius, and whether you want it filled, framewire, etc. To draw an ellipse, you provide the same information you would for a rectangle (upper-left and lower-right corners), but it draws an ellipse in that rectangle.void DrawCircle (int centerX, int centerY, int radius, FILLED);
void DrawEllipse (int leftWall, int topWall, int rightWall, int bottomWall, FILLED);
Save your modifications.
Do remember to save your code, though. Remove the object code from the project, and copy the Histogram Lab folder from the Temp folder to your floppy disk. You should then remove the folder from the Temp folder on the C: drive.
The Balloon Race
*The CMU Graphics Library was created by the Carnegie Mellon University School of Computer Science and is used in their introductory programming courses. It is available from Mark Stehlik's Advanced Placement page.