CS-1030 Software Design 2
Lab 5: Drawing Graphical Shapes

Objectives

Assignment

In this lab, you will complete a Windows GUI application that creates and draws a variety of graphical shapes.

The UML diagram illustrating the skeletal structure of this application is shown below:

This application has been partially written for you; you can download the code here. The partially-written classes are GraphicShapesApp and GraphicShapesUI; you will (probably) add some private member variables to these classes. Note that the member attributes and methods of these classes are not shown in the UML diagram.

The classes Shape, Square, Circle, and Line are left entirely to you to implement.

The GraphicShapesApp class is the main class that contains all the necessary code to start the application running; you don't have to modify anything within this class. GraphicsShapeApp creates an instance of GraphicShapesUI, which implements the main part of the GUI aspect of the application.

GraphicsShapeUI is, additionally, the creator of the ShapeCollection object and all Shape-derived objects that the collection contains. You'll have to modify GraphicsShapeUI. There are comments within the existing file that advise you where you have to make additions; look for the comments containing "CS1030 TODO". For instance, GraphicShapesUI has an incomplete implementation of the event-handling methods that create and draw the graphical shapes in a window, and you have to complete these methods.

The various event-handling methods handle the following types of events:

Follow the "CS1030 TODO" comments to get clues on what you have to do in each method.

Your Shape class is an abstract base class (non-instantiable) that represents generic shapes. The Line, Square, and Circle classes derive from Shape and are instantiable. Each Shape-derived object connects, or point to, additional instances of Shape-derived objects, via a private nextShape pointer in the parent Shape class. The last Shape-derived object in the chain will contain a NULL nextShape pointer (each time a Shape-derived object is created, the base class (Shape) constructor should initialize this pointer to NULL).

You should not have to add additional methods to these four classes; follow the UML diagram as you implement them. See me first if you believe otherwise.

When this application exits, it has to clean up - that is, it has to delete() all of the Shape-derived objects in the chain, as well as the ShapeCollection object. Note that when you invoke the delete() operator on a Shape pointer (to an Shape-derived object), that object's destructor is automatically called provided that the Shape destructor is virtual. Thus, you must make the Shape destructor a virtual method.

Furthermore, you should write the ShapeCollection destructor in such a fashion that it in turn deletes the first Shape-derived object in the collection, whose destructor in turn deletes the second Shape-derived object in the collection, and so on, until all objects have been destroyed.

Lab Activities

  1. Using Enterprise Architect, add a UML Sequence Diagram to the UML diagram that illustrates the call sequence following a mouse button up event, where a Shape-derived object is created and added to the ShapeCollection collection. Finish this diagram by the end of the lab period. Ask me for assistance.
     
  2. Modify your program according to the preceding description.

Demonstration

You must demonstrate your working program during the week 8 lab period (start of lab 6).

Lab Report

This is a 1 week lab. The lab report and program is due by 11:00pm Tuesday, May 2, 2006.

Submit your completed assignment following these instructions:
  1. Navigate to your VS .NET project directory (see this note on configuring the workspace).
  2. You should have a subdirectory under your VS .NET project directory with the name of the project you used for this lab. 
  3. Upload your submission through WebCT (assignment "Lab 5 Graphical Shapes"), selecting only the .cpp, .h, .sln, .vcproj, and .doc files from this directory. Upload each file separately; do not zip files. Paste the UML sequence diagram into your report; do not send the .EAP file.
  4. Enter the overall time you spent on this lab into the FAST system (for week 7).
Be sure to keep copies of all your files, in case something gets lost.

Your lab grade will be determined by the following factors:

Program quality Report quality