This assignment uses the acm.graphics package developed by the ACM and SIGCSE Java task Force, in particular the turtle graphics class GTurtle. It can easily be adapted to other packages that include graphical objects with position, direction and movement.
Suppose that we would like to model turtles that dance. One kind of turtle will move according to a dance step pattern that is specified by a sequence of directions in which the turtle is to move. This type of turtle is a lead dancer. A second kind of turtle is the follower; this turtle will have a reference to another turtle and will mimic its moves by moving in the same direction on each move. Observe that both types of turtle have a specified direction in which they will move on each step.
When we analyze the development of related (turtle) classes like these and see some characteristics in common, it suggests a design where we put the common elements into an abstract class. Then the specific types of turtle, the leader and the follower, will each be specified by a class that extends this abstract class and specifies how the direction for each step is determined.
This type of turtle has a list of directions. For each step it selects the next direction from the list, starting with the first in the list. When the list is exhausted, it starts again at the beginning of the list. For each step it moves a fixed amount in the direction for that step.
This type of turtle is assigned another turtle as its "leader" when it is constructed (this means that the other turtle must exist before this turtle is created). The leader can be passed as a parameter to the constructor. This turtle takes the current direction of its leader as the direction for its step. For each step it moves a fixed amount in the direction for that step.
The last sentence of these two specifications are the same!
Describe an inheritance hierarchy that consists of an abstract class (perhaps called DancingTurtle) that encapsulates the common features of these two specifications, and a class representing each of the two types of turtle that extend this abstract class so as to implement their specifications. Your descriptiuon should clearly indicate the methods and the instance variables (if any) for each class. An annotated diagram is a good way to represent this design.
Write the code for the three classes in this inheritance hierarchy. Write a driver class that tests your turtles.
Consider making dancing turtles that follow a leader in a circle or a conga line. This cannot be done with the two types of turtle described above but could be done with the following turtles, both of which extend the same DancingTurtle class. The leader will take a list of angles for the amount to turn left on each step, and set its direction accordingly. The follower will again have a reference to a leader but will set its direction so that it makes the same turn as the leader. A variation that would make a good conga line would be to have the follower make the same turn that the leader did on the previous step. Implement and test these dancing turtles.