CS177/457 C++ Programming
Spring 1998
Feeding time: Dynamic allocation and virtual functions
Introduction
Your program will print out a feeding schedule for all the animals in the zoo. Different kinds of animals have different feeding requirements--type of food, amount of food and how it is to be delivered.
Requirements
There are three kinds of animals in our zoo: mammals, reptiles and birds. In the mammals, we have two tigers, Kuma, and Aralta; a donkey, Phil, and a panda LimLim. Amongst the reptiles we have an anaconda called Fred, two iguanas, Charles and Diana, and a crocodile called Sugar. The birds don't have names, but numbers: six lesser crested thrushes, numbers 4725 through 4730, a horn-billed parrot, number 2122, and ten north American starlings, numbers 3010 through 3019. It's a small zoo!
The feeding requirements are in the table below:
Animal |
Type of food |
Amount |
Delivery |
tiger |
beef |
10 pounds |
remote |
donkey |
hay |
5 pounds |
pen |
panda |
bamboo leaves |
20 pounds |
remote |
anaconda |
live rat |
1 |
cage |
iguana |
crickets |
25 |
cage |
crocodile |
dead rat |
6 |
remote |
thrush |
seeds |
2 ounces |
pen |
parrot |
seeds |
4 ounces |
hand |
starling |
live bugs |
1 ounce |
cage |
Your program should be able to add new animals, store the information in a database and print feeding requirements of all the animals in the zoo.
Hints and notes
Deliverables
int main() {
vector<Animal*> zoo;
zoo.push_back(new Donkey("Phil"));
zoo.push_back(new Anaconda("Fred"));
…
for (int animal = 0; animal < zoo.size(); animal++)
zoo[animal]->printFeedingRequirements();
}
Due Date
Friday 24th. April at 5 pm.