next up previous contents
Next: Question 2 (20 points) Up: Questions Previous: Questions   Contents

Question 1 (20 points)

Design and implement an inheritance hierarchy to model the animal kingdom (i.e. the animal taxonomy). There is no need to implement the full taxonomy. Only that part of the taxomony necessary to populate your hierarchy with ten different animals is required. Your sample should at least include one reptile, one mammal, one fish and one amphibian. Write a driver program that asks the user for how many animals (s)he wants in his/her zoo. Use this input to randomly create the necessary animals and store them in a container class. Write methods to allow the zookeeper to add/delete random animals and to take stock.

Answer in the comments of your driver class why asking a list of all mammals would be a breach of ploymorphism. How could you solve this problem?



Marina De Vos 2004-10-28