organism.h:
Header file for the Organism class and various derived classes.
You don't have to write much of this file.
Just copy our version from
~main2270/programs/organism.h
and add your name and other information at the top.
You'll also need to add the Carnivore class declaration at the
bottom.
organism.cxx:
This file should contain the implementations of the Organism
class and the various derived classes (Plant, Herbivore, and Carnivore).
You should start with our version from
~main2270/programs/organism.cxx
.
You'll need to add the Carnivore's constructor and the
chase
member function.
ecosystem.cxx:
A demonstration program that shows how the new Carnivore class might
be used in a program that simulates a small ecosystem. By the way,
the program works at the moment, but the constants that I set at
the top may not be very stable. At the moment (April 29) these
constants cause the foxes to quickly die out and then the goose
population explodes. We'll play around with these constants when
I discuss the program in class on May 2. Note: In order to compile
and run the ecosystem program you'll also need to grab
bag8.h
,
bag8.template
,
link2.h
, and
link2.template
.
makefile.eco:
This is a makefile for the assignment.
You can copy it to your directory and change the name to just
makefile
.
You should be able to program this in a few minutes after you read
Sections 14.1 and 14.2. However, if your copy of the textbook
is the first printing, then the chase
member function
on page 660 has two bugs:
rand()/MAX_RAND
is incorrectly an integer division.
You need to change this so that the result of the division is
a double number.