import structure.*; import java.util.*; /** * This class represents one creature on the board. * Each creature must remember its species, position, direction, * and the world in which it is living. *

* In addition, the Creature must remember the next instruction * out of its program to execute. *

* The creature is also repsonsible for making itself appear in * the WorldMap. In fact, you should only update the WorldMap from * inside the Creature class. */ public class Creature { /** * Create a creature of the given species, with the indicated * position and direction. Note that we also pass in the * world-- remember this world, so that you can check what * is in front of the creature and to update the board * when the creature moves. */ public Creature(Species species, World world, Position pos, int dir) { } /** * Return the species of the creature. */ public Species species() { Assert.fail("Implement me."); return null; } /** * Return the current direction of the creature. */ public int direction() { Assert.fail("Implement me."); return 0; } /** * Return the position of the creature. */ public Position position() { Assert.fail("Implement me."); return null; } /** * Execute steps from the Creature's program until * a hop, left, right, or infect instruction is executed. */ public void takeOneTurn() { } /** * Return the compass direction the is 90 degrees left of * the one passed in. */ public static int leftFrom(int direction) { Assert.pre(0 <= direction && direction < 4, "Bad direction"); return (4 + direction - 1) % 4; } /** * Return the compass direction the is 90 degrees right of * the one passed in. */ public static int rightFrom(int direction) { Assert.pre(0 <= direction && direction < 4, "Bad direction"); return (direction + 1) % 4; } /** */ public static void main(String st[]) { // test creature code here. } }