demo
Class CarryDropAgent

java.lang.Object
  extended bydemo.CarryDropAgent
All Implemented Interfaces:
uchicago.src.sim.gui.Drawable

public class CarryDropAgent
extends java.lang.Object
implements uchicago.src.sim.gui.Drawable

Agent for the CarryDrop model. The agent includes basic internal variables, methods for modifying an agent's position and direction, ID variables, etc.

Author:
John T. Murphy
University of Arizona, Department of Anthropology
Arizona State University, Center for Environmental Studies

Constructor Summary
CarryDropAgent(int minLifeSpan, int maxLifeSpan)
          Constructor that takes the ranges of permissible life spans
 
Method Summary
 void draw(uchicago.src.sim.gui.SimGraphics G)
          Draw this agent to the RePast graphics object.
 java.lang.String getID()
          Get this agent's internal unique ID
 int getMoney()
          Get the amount of money held by this agent
 int getStepsToLive()
          Get the number of steps this agent has remaining in its 'stepsToLive' variable.
 int getX()
          Get this agent's X position
 int getY()
          Get this agent's Y position
 void receiveMoney(int amount)
          Receive an amount of money and put it in the agent's holdings.
 void report()
          Prints a report on this agent's status variables to the System output
 void setCarryDropSpace(CarryDropSpace cds)
          Set this agent's pointer to the space object in which it resides.
 void setXY(int newX, int newY)
          Set a new X and Y position for the agent.
 void step()
          A basic 'step' for this agent- the actions it takes when it is the agent's 'turn' in the simulation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CarryDropAgent

public CarryDropAgent(int minLifeSpan,
                      int maxLifeSpan)
Constructor that takes the ranges of permissible life spans

Parameters:
minLifeSpan - Shortest possible life span
maxLifeSpan - Longest possible life span
Method Detail

setXY

public void setXY(int newX,
                  int newY)
Set a new X and Y position for the agent. Note that this affects only the agent's internal assessment of its own location, and thus should be called only after the Space object has confirmed that this location is acceptable.

Parameters:
newX -
newY -

setCarryDropSpace

public void setCarryDropSpace(CarryDropSpace cds)
Set this agent's pointer to the space object in which it resides.

Parameters:
cds - The space object into which the agent is being placed

getID

public java.lang.String getID()
Get this agent's internal unique ID

Returns:
a String representing the unique ID for this agent; this will be in the form "A-101"

getMoney

public int getMoney()
Get the amount of money held by this agent

Returns:
the amount of money this agent has

getStepsToLive

public int getStepsToLive()
Get the number of steps this agent has remaining in its 'stepsToLive' variable.

Returns:
the number of steps until this agent dies

report

public void report()
Prints a report on this agent's status variables to the System output


getX

public int getX()
Get this agent's X position

Specified by:
getX in interface uchicago.src.sim.gui.Drawable
Returns:
the agent's X position

getY

public int getY()
Get this agent's Y position

Specified by:
getY in interface uchicago.src.sim.gui.Drawable
Returns:
the agent's Y position

draw

public void draw(uchicago.src.sim.gui.SimGraphics G)
Draw this agent to the RePast graphics object.

Specified by:
draw in interface uchicago.src.sim.gui.Drawable
Parameters:
G - the graphics object to which this agent will be drawn

step

public void step()
A basic 'step' for this agent- the actions it takes when it is the agent's 'turn' in the simulation


receiveMoney

public void receiveMoney(int amount)
Receive an amount of money and put it in the agent's holdings.

Parameters:
amount - the amount of money received