appletbots
Class CarrierAgent

java.lang.Object
  extended by appletbots.WorldObject
      extended by appletbots.Agent
          extended by appletbots.CarrierAgent
Direct Known Subclasses:
Gatherer

public abstract class CarrierAgent
extends Agent

This class represents an agent that can pick up objects in the appletbots world.

Author:
Erik Rasmussen

Field Summary
 
Fields inherited from class appletbots.Agent
accelerationVectorColor, maxAcceleration, sight, velocityVectorColor, world
 
Fields inherited from class appletbots.WorldObject
color, mass, maxSpeed, size
 
Constructor Summary
CarrierAgent(int pickUpDistance, int size, int sight, double maxSpeed, double maxAcceleration)
          Constructs an agent with the given parameters
 
Method Summary
protected  void drop(CarriableObject item)
          Drops an object
 CarriableObject[] getInventory()
          Returns the contents of the agent's inventory
 int getPickUpDistance()
          Returns the distance the agents needs to be from an object to be able to pick it up
 boolean hasItem(CarriableObject item)
          Returns whether or not the agent is carrying the given item
 boolean hasItems()
          Returns whether or not the agent is carrying any items
protected  void pickUp(CarriableObject item)
          Picks up an object
 
Methods inherited from class appletbots.Agent
getAcceleration, getMaxAcceleration, getRandomAcceleration, getShowAcceleration, getShowVelocity, getSight, getVectorsToDraw, observeWorld, setAcceleration, setShowAcceleration, setShowVelocity, setWorld
 
Methods inherited from class appletbots.WorldObject
collidedWith, getColor, getMass, getMaxSpeed, getSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CarrierAgent

public CarrierAgent(int pickUpDistance,
                    int size,
                    int sight,
                    double maxSpeed,
                    double maxAcceleration)
Constructs an agent with the given parameters

Parameters:
pickUpDistance - How close a CarrierAgent must be to an object to pick it up
size - The agent's radius
sight - The distance the agent can see
maxSpeed - The maximum speed the agent can travel
maxAcceleration - The maximum acceleration for this agent
Method Detail

pickUp

protected void pickUp(CarriableObject item)
Picks up an object

Parameters:
item - The object to pick up

drop

protected void drop(CarriableObject item)
             throws CollisionException
Drops an object

Parameters:
item - The object to drop
Throws:
CollisionException - Thrown if the item cannot be dropped within the "pickup distance"

hasItem

public boolean hasItem(CarriableObject item)
Returns whether or not the agent is carrying the given item

Parameters:
item - The item to check for
Returns:
Whether or not the agent is carrying the given item

hasItems

public boolean hasItems()
Returns whether or not the agent is carrying any items

Returns:
Whether or not the agent is carrying any items

getInventory

public final CarriableObject[] getInventory()
Returns the contents of the agent's inventory

Returns:
The contents of the agent's inventory

getPickUpDistance

public int getPickUpDistance()
Returns the distance the agents needs to be from an object to be able to pick it up

Returns:
The distance the agents needs to be from an object to be able to pick it up