CS 3100, Fall 2021
Due Wednesday, May 26, 2021 at midnight
Shapes, Shapes, so many Shapes

Loosely based on an assignment created by Dr. Melanie Martin of CSU Stanislaus.


All work on this assignment must be your own. You should not look at any other student's plans or code (in whole or in part, on paper or on screen), nor allow any other student to look at yours, during the course of this assignment.


The purpose of this assignment is to get a better understanding of inheritance in C++ by writing and using derived classes.

Base class: we will use a modified version of sphere class from an old edition of the book. Here is code for Sphere.h, Sphere.cc, Shape.h and Shape.cc.

You will write three classes: Square, Colored Sphere, and a driver program.

Square is a derived class of Shape with added data "length". The displayStatistics() method of Square needs to display the Shape data, plus the length and perimeter data.

ColoredSphere is a derived class of Sphere with added data "color". The displayStatistics() method will also need to be modified to display Sphere data plus the color. (The color data will simply be a string variable, storing the name of the desired color.)

Write a driver program, named homework4.cc, that allows the user to create and display all instances of all three classes. The driver should provide a menu of options for the user and allow the user to continue creating and viewing class instances until the user desires to stop.

The user may create as many shapes as they wish. When they choose to view their shapes, your program should display information about all of the shapes the user has created since the program began running.

(At the user's discretion, the user may create a new Sphere, a new ColoredSphere, a new Square, or display information about all the previously created shapes, as many times as the user wants.)

As an example to start work on your driver (homework4.cc) program, consider the sample program on page 61 (Chapter 2, Figure 2.8) of your textbook. That program is a simple driver for the Throttle class. As another example, testShape.cc is a (very simple) driver for Sphere.

Hint: Consider one of the STL Containers to store your collection of Shapes in.

You may add additional data and functionality to your classes as desired. You may not modify Shape or Sphere source code.

(If you think there is a compelling reason to change Shape or Sphere, contact the professor. Any change made will apply to the code used by the entire class.)

Test Results. In mytesting.txt include an example of you testing your own program. Run your program, go through all of your menu options (except stop) more than once, and copy-and-paste all of your program run into mytesting.txt.

Insights and Lessons Learned. In readme.txt include a paragraph or two describing what you learned from writing and testing this program. Do your very best to make this well-written.

The readme.txt file must also contain a compile command that works, for you, to compile your shape and driver code and produce an executable program.


What To Turn In:

Here is the list of things you have to turn in:
  1. Upload to Canvas before midnight on the due date