|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCreature
public class Creature
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.
Constructor Summary | |
---|---|
Creature(Species species,
World<Creature> world,
Position pos,
int dir)
Create a creature of the given species, with the indicated position and direction. |
Method Summary | |
---|---|
int |
direction()
Return the current direction of the creature. |
static int |
leftFrom(int direction)
Return the compass direction the is 90 degrees left of the one passed in. |
static void |
main(String[] st)
This main program reads in one species, creates one creature, and gives it twenty turns. |
Position |
position()
Return the position of the creature. |
static int |
rightFrom(int direction)
Return the compass direction the is 90 degrees right of the one passed in. |
Species |
species()
Return the species of the creature. |
void |
takeOneTurn()
Execute steps from the Creature's program until a hop, left, right, or infect instruction is executed. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Creature(Species species, World<Creature> world, Position pos, int dir)
Method Detail |
---|
public Species species()
public int direction()
public Position position()
public void takeOneTurn()
public static int leftFrom(int direction)
public static int rightFrom(int direction)
public static void main(String[] st)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |