Description
Design, write, compile, and test a program that uses polymorphism in inheritance
This module builds on the previous module. You will receive feedback as soon as possible.
Save a copy of the previous module so you have a known place to start in case of
catastrophe! Design your changes. Review the design. Then, and only then, start coding!
You will modify your program to add a new Critter: Doodlebug. You can start by copying Ant
and make necessary changes. Both will inherit from Critter.
You will change your array(s) back to point to Critter. That should be the only change to the
main program.
Modify your class hierarchy and review your algorithms. What must you change? What new
algorithms do you require?
Critter will have a virtual function Breed(). Doodlebug will still use Breed(). Doodlebugs breed after
8 steps. They (obviously?) create a new Doodlebug and not an Ant. Are any other changes needed?
Critter will have a virtual function Eat(). If a Doodlebug moves into a grid with an Ant it will eat the
ant. An Ant will not eat another Ant. A Doodlebug will not eat another Doodlebug.
The Doodlebug will have a function Starve() which counts the steps taken by that Doodlebug. If it
moves 3 steps and hasn’t eaten it will die. Do you need any new member variables to support this?
Is there anything else you need? Then finish modifying your inheritance hierarchy. Make sure
you write out, develop and test any new algorithms. Please don’t tell me that you still start coding
rather than designing first. J
Grading
Modules will be graded S/U. As part of the cumulative modular program (Cump) this module
will contribute to that numeric score. These criteria are given for reference.
Programming style- 10%
Modify the class hierarchy and design- 20%
The move() function works correctly for both derived classes using *Critter- 30%
The Starve() function is implemented and used correctly- 10%
Doodlebug::Breed() correctly creates the new Doodlebug object- 10%
The ‘parent’ Doodlebug moves correctly, leaving the new Doodlebug in the original cell – 10%
Submit all files in zip archive- 10%