Orca
Category: Critters
Author: Stuart Reges
Book Chapter: 9.2
Problem: Orca
Write a class called Orca that extends the Critter class. The instances of the Orca class follow a pattern of moving forward four times, then turning around, then moving back four times and turning around again so that they return to their original position and direction. Each Orca is always either in moving-mode or in turning-mode. They start out in moving-mode. While in moving-mode, they try to hop forward if possible until they have hopped four times, at which point they switch into turning-mode. If it is not possible to hop while in moving-mode, an Orca instead infects whatever is in front of it. When in turning-mode, the Orca turns left twice and then switches back to moving-mode. Don't worry about the fact that if the Orca encounters a wall while in moving-mode, it gets stuck trying to infect the wall indefinitely. The Orca displays itself as "M" while in moving-mode and as "T" while in turning-mode. Its color should be the default color for critters.