Ant Farm - Robert Glen Martin
School for the Talented and Gifted
Dallas I.S.D.

Class Food

java.lang.Object
  extended by info.gridworld.actor.Actor
      extended by Food
All Implemented Interfaces:
Processable
Direct Known Subclasses:
Cake, Cookie

public abstract class Food
extends info.gridworld.actor.Actor
implements Processable

Food is the top level abstract class for different types of food. A food object waits for a WorkerAnt to get food from it. It does not act.


Field Summary
private  int BITE_SIZE
          The size of a bite
private  int foodEaten
          The total amount of food eaten
 
Constructor Summary
Food(int bite)
          Constructs a Food actor.
 
Method Summary
 void act()
          "Do nothing" act method.
 void process(WorkerAnt ant)
          Gives food and current location to ant.
 java.lang.String toString()
          Creates a string that describes this actor.
 
Methods inherited from class info.gridworld.actor.Actor
getColor, getDirection, getGrid, getLocation, moveTo, putSelfInGrid, removeSelfFromGrid, setColor, setDirection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BITE_SIZE

private final int BITE_SIZE
The size of a bite


foodEaten

private int foodEaten
The total amount of food eaten

Constructor Detail

Food

public Food(int bite)
Constructs a Food actor. The image is displayed for this actor without tinting.

Method Detail

process

public void process(WorkerAnt ant)
Gives food and current location to ant.

Specified by:
process in interface Processable
Parameters:
ant - the calling WorkerAnt

act

public void act()
"Do nothing" act method. This is provided for the Ant Farm Cake, Cookie, and QueenAnt classes which do not act.

Overrides:
act in class info.gridworld.actor.Actor

toString

public java.lang.String toString()
Creates a string that describes this actor.

Overrides:
toString in class info.gridworld.actor.Actor
Returns:
a string with the Actor information plus the amount of food eaten from this Cake

© 2007 Robert Glen Martin.
All rights reserved.