[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci & Eng] / [R J Botting] / [CSci202] / lab05
[Text Version] [Syllabus] [Schedule] [Glossary] [Resources] [Grading] [Contact] [Question] [Search ]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]
Labs: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10]
Mon Apr 26 16:47:54 PDT 2010


    Lab 05 Inheritance and Polymorphism

    Download a Dia model and some initial code

    [ lab05.dia ] (Dia) [ shapes.cpp ] (C++)

    Note -- Dia does not execute files in the FIrfox browser.... use a "right-click" to save the file and open it using the "File" menu inside "Dia".

    Study the two files

    You will need to look inside the classes in the diagram... double click them. They contain some formulas you will need to translate into C++ to complete the laboratory.

    Study the ".cpp" file. Because this is a laboratory experiment I have not set it up as a fully engineered set of files. All the code is to be put into the same file. You will be adding new classes to this file.


    A completed implementation and test of all the classes in the Dia model -- all in a single compilable "shapes.cpp" file.


    1. Open and explore the Dia model for this lab.
    2. View the shapes.cpp file in an editor to see what is present and what is missing.
    3. Compile and run shapes.cpp as is.
    4. Move the start of the comment "/******" down to exclude a test of Circle.
    5. Implement and test Circle.
    6. Move the start of the comment "/******" down to exclude a test of Rectangle.
    7. Implement and test Rectangle.
    8. Move the start of the comment "/******" down to exclude a test of EquilateralTriangle.
    9. Implement and test EquilateralTriangle.

    Grading -- how many classes have you got to work in 2 hours

    Too easy -- finish early

    Work on the next project that is due.


  1. Algorithm::=A precise description of a series of steps to attain a goal, [ Algorithm ] (Wikipedia).
  2. class::="A description of a set of similar objects that have similar data plus the functions needed to manipulate the data".
  3. Data_Structure::=A small data base.
  4. Function::programming=A selfcontained and named piece of program that knows how to do something.
  5. Gnu::="Gnu's Not Unix", a long running open source project that supplies a very popular and free C++ compiler.
  6. KDE::="Kommon Desktop Environment".
  7. object::="A little bit of knowledge -- some data and some know how", and instance of a class".
  8. OOP::="Object-Oriented Programming", Current paradigm for programming.
  9. Semantics::=Rules determining the meaning of correct statements in a language.
  10. SP::="Structured Programming", a previous paradigm for programming.
  11. STL::="The standard C++ library of classes and functions" -- also called the "Standard Template Library" because many of the classes and functions will work with any kind of data.
  12. Syntax::=The rules determining the correctness and structure of statements in a language, grammar.
  13. Q::software="A program I wrote to make software easier to develop",
  14. TBA::="To Be Announced", something I should do.
  15. TBD::="To Be Done", something you have to do.
  16. UML::="Unified Modeling Language".
  17. void::C++Keyword="Indicates a function that has no return".