CS Logo

Project 4 (Final Project)


You are going to implement several dinosaurs. You can accomplish this by defining several different classes (one for each type of dinosaur) or one complex class that can be any type of dinosaur. It is up to you.


  • Apatosaurus (a very large, herbivorous, slow-moving dinosaur)
  • Tyrannosaurus Rex (a large, carnivorous, fast dinosaur)
  • Hadrosaur (a medium-sized, herbivorous, fast dinosaur)
  • and one or more dinosaurs of your choosing.


Each dinosaur contains the following private data members:


1) Weight

2) Length

3) Height

4) Name

5) Diet (Carnivorous or Herbivorous)

6) Color. Any color you want.

7) Sound. A string that specifies the noise the dinosaur makes

8) Speed


Create a constructor which allows the creator of the object to specify the

private data member values and which prints "a <color> <name> just hatched."


Create a destructor which prints "A <color> <name> died."


Write a stats method, sleep method, an eat method, a make_noise  method, and a procreate method..


The stats method prints the private data members.


When the sleep method is called the dinosaur object prints "a <color> <name> was tired and fell asleep."


For herbivores the eat method takes no arguments and just prints "a <color> <name> ate some plants" and increases the height, size, and weight of the herbivore by some amount.


For carnivores the eat method takes an argument which is a pointer to another dinosaur object. You will have to write an overloaded eat method for each of your dinosaur classes so that the carnivore is able to eat different kinds of dinosaur. The carnivore eat method prints "A <carnivore color> <carnivore name> ate a <argument dinosaur color> <argument dinosaur name>!" calls delete on the dinosaur object that was eaten and increases the height, size, and weight of the dinosaur doing the eating by some amount.


The make_noise method prints the string specified in sound.


The procreate method takes no arguments and returns a pointer to a new dinosaur object of the same type as the one upon which procreate was called.


Write driver.cpp which instantiates your dinosaurs using the new operator, prints the attributes for each dinosaur, and goes through the various behaviors we defined for the dinosaurs.


When you turn in your project include a Makefile for compiling your program.


Creating classes that store the specified data (10 points)

Constructor (10 points)

Destructor (5 points)

procreate (10 points)

eat (15) points

stats (5 points)

sleep (5 points)

make_noise (5 points)


15 points for coding style.


20 points for exhibiting the behavior of your dinosaur objects in interesting ways. Use of loops and the rand function to determine interactions would be especially impressive.


If I cannot compile your code using your Makefile zero points will be awarded. There is no such thing as "almost compiles."