
CIS 554 Homework 3
Homework Objective: Provide students with an opportunity to understand and become comfortable with
creating classes and test drivers for the class. This homework provides the opportunity for the student to
use composition, as well as demonstrate separation of interface from implementation.
Description: Rectangle Screen Saver
1. First, write a Rectangle class. It must be called MyRect. The class should have at least the following
public methods. You can provide more if necessary.
Draw (draws rectangle on screen per the defined fill and border parameters)
SetLength, SetWidth
SetFillColor, SetBorderColor, SetBorderWidth
SetPosition (upper left corner x,y coordinate)
2. Your MyRect class will use the services of the FilledShapes class to draw the rectangle. I.e.,
MyRect will be composed of a FilledShapes class. Note that FilledShapes provides other shapes
(e.g. circle, ellipse and triangle) but you are only to use the FilledShapes::FilledRectangle service.
We will use the other shapes in a future homework. I have provided an example program on the web
of how FilledShapes can be used.
3. To test your MyRect class, include a test driver at the end of the class implementation. It will only be
compiled if TEST_DRIVER is defined in the C++ environment.
4. The test driver should test all methods, including error conditions (like too big to fit on screen, or
can’t be drawn at current position due to its size.)
5. Finally, you are to write a program that creates and manages 5 rectangles. Your program will
randomly draw the five rectangles on the screen, with random fill colors, border colors and border
width. The program should loop N times (you can hard-code N into your program). With each loop, it
will randomly select parameters, and draw the rectangles. You can use FilledShapes::ClearScreen to
clear the screen before each loop.
6. The MyRect class and program must be well structured, with comments, file headers, member
function headers, and indentations. I will be looking for interface files (i.e. .h files) that have a clear
and concise description of what the MyRect class’s capabilities are. No skimping on comments! The
interface file must be separate from the implementation file (i.e. I expect a .h and a .cpp file). The
Test Driver should be part of the class implementation file (.cpp file).
7. Add doxygen to your MyRect class.
8. You may NOT modify FilledShapes.h.
Submission Format: Provide the information as follows:
1. Please create a .zip archive of all your files. There should be 3 files in the .zip archive: MyRect.h,
MyRect.cpp, and screensaver.cpp.
2. Upload the .zip archive via the web upload link. Please make sure you append the zip file name with
_HW3.zip