Lab 05 Inheritance and Polymorphism
Download a Dia model and some initial code
[ lab05.dia ]
[ shapes.cpp ]
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
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.
- Open and explore the Dia model for this lab.
- View the shapes.cpp file in an editor to see what is present and what is missing.
- Compile and run shapes.cpp as is.
- Move the start of the comment "/******" down to exclude a test of Circle.
- Implement and test Circle.
- Move the start of the comment "/******" down to exclude a test of Rectangle.
- Implement and test Rectangle.
- Move the start of the comment "/******" down to exclude a test of EquilateralTriangle.
- 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.
- Algorithm::=A precise description of a series of steps to attain a goal,
[ Algorithm ]
- class::="A description of a set of similar objects that have similar data plus
the functions needed to manipulate the data".
- Data_Structure::=A small data base.
- Function::programming=A selfcontained and named piece of program that knows how to do something.
- Gnu::="Gnu's Not Unix", a long running open source project that supplies a
very popular and free C++ compiler.
- KDE::="Kommon Desktop Environment".
- object::="A little bit of knowledge -- some data and some know how", and
instance of a class".
- OOP::="Object-Oriented Programming",
Current paradigm for programming.
- Semantics::=Rules determining the meaning of correct statements in a language.
- SP::="Structured Programming",
a previous paradigm for programming.
- 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.
- Syntax::=The rules determining the correctness and structure of statements in a language, grammar.
- Q::software="A program I wrote to make software easier to develop",
- TBA::="To Be Announced", something I should do.
- TBD::="To Be Done", something you have to do.
- UML::="Unified Modeling Language".
- void::C++Keyword="Indicates a function that has no return".