CPE 102 Lab 08 - Structural Recursion

Goals

Resources

Orientation

You will implement a system of classes to represent a TotemPole for the fictional Gashunonga Tribe.  A TotemPole is compromised of different animial heads (Bear, Snake, and Eagle).  Every TotemPole has an Eagle at the top.  Eagles can only be at the top of the pole.  Each animal head adds a different amount of power to the TotemPoleBears are the most sacred to the Gashunongan people and add 5 power points to the TotemPoleSnakes add 3 power points.  Eagles add 2 power points.  Since Bears are the most sacred, a Gashunongan Chief's TotemPole must have at least 3 Bears in a row at some place in the TotemPole.

                     Totem Pole

Specification

Develop the following interface and classes:

        Develop an interface called TotemPoleA TotemPole has the following methods:
         int power();  // the total power of the pole
         int height(); // the number of heads in the pole
         boolean chiefPole(int bearCount);  // is this pole worthy of a chief?
                 // bearCount is how many bears encountered in a row so far


        Develop the class Bear that implements the TotemPole interface.  Bears have the following constructor:
         public Bear(TotemPole rest);

        Develop the class Snake that implements the TotemPole interface.  Snakes have the following constructor:
         public Snake(TotemPole rest);

        Develop the class Eagle that implements the TotemPole interface.  Eagles have the following constructor:
         public Eagle();

Testing

Test your solution using the TotemTest class that I (Prof. Workman) have written for you.

Lab courtesy of Julie Workman.