The final exam is split into two parts. 100 points will be from final programming projects and another 100 points
from in-class exam, given during the regularly scheduled time: - Saturday, December 14, 6:30-9:30 p.m. in the usual
classroom. Programming part is due that time.
The programming project has two parts (two separate programs):
Part A (Recursion): Programming Project number 7 on page 793 of the textbook, the Towers of Hanoi Problem.
Part B (Inheritence): Define classes that satisfy the following conditions and the hierarchy in the diagram
given in the class.
- A definition of an object, for a class in the bottom of the hierarchy, should produce a message consisting
of the names of all the classes that directly or indirectly are related to the object.
- A defiition of an object for a class not in the bottom of the hierarchy should prompt the compiler to issue
an error message.
- Each defined object should be able to respond to the following functions.
- talk-- A parameter-free function that produces a message from the object.
- xivore-- A parameter-free function that produces one of "carnivore" or "herbivore" that
reflects the kind of object in discourse.
- Each of the classes is allowed to explicitly declare at most two member functions, with at most one of the
two not being a constructor.
- The body of each member function should be a single command of the form cout<<" ....";
- A string containing the name of a class may appear only within members of the class. (That is, if A is a name
of a class and x is a string "...A..." referring to A, then x may only be included within members of
A)
Example: The program
#include ...
//missing definitions
int main( )
{
leopard a;
a.talk( );
a.xivore( );
return 0;
}
should produce an output of the following form.
animals carnovore cats leopard
leooo
carnivore