Skip to content

CS 1415 - Lab #10

Objectives:

Program with composition and inheritance

Preparation:

Review Sections 14.7 and 15.1-15.6 from Starting Out with C++ by Gaddis

Assignment:
  1. Place each class in its own library.  Name the library files LlllFfffClass.h and LlllFfff'Class.cpp where Llll is the first four letters of your last name and Ffff is the first four letters of your first name, and Class is the name of the class contained in the particular file.  Name your driver file LlllFfffLab10.cpp.  There will be seven files in all.
  2. Create a Point class to represent a point in two dimensions. Provide an explicit value constructor with default arguments. Provide set and get functions. Overload the output operator to display the Point in the form (x,y).
  3. Create a Square class that has-a lower-left point and a side length. Provide an explicit value constructor with default arguments. Also provide a function to set the lower-left point and a function to set the side length. Provide get functions to get the side length and to get the area. Overload the output operator to output a Square by simply outputting the attributes (data members) of the square in a reasonable format.
  4. Create a Cube class that is-a Square. Provide an explicit value constructor with default arguments. Redefine the get function that gets the area so that it gets the surface area. Also provide a get function to get the volume. Ensure that the output operator correctly outputs a Cube in a reasonable format.
  5. Write a driver program to demonstrate the three classes. The driver should create an instance of each of the three classes. The user should be allowed to specify values for all three (you may utilize the constructors and/or set functions). Then it should output all three objects.
  6. Verify your program works correctly.
  7. Submit your source code files to ude.wons@nosneros.htrag. Due at 8:00 am on 10 March.