Class DEAgent

java.lang.Object
  extended by SimpleTurtle
      extended by Turtle
          extended by Agent
              extended by DEAgent
Direct Known Subclasses:
Distributor, Truck

public class DEAgent
extends Agent

DEAgent - an agent in a Discrete Event simulation A DEAgent doesn't act(). A DEAgent adds events to the queue, and requests resources.


Field Summary
 
Fields inherited from class Agent
MAX_SPEED, PROB_OF_STAY, randNumGen
 
Constructor Summary
DEAgent(int x, int y, ModelDisplay modelDisplayer, Simulation thisSim)
          Constructor that takes the x and y, and a model display to draw it on, and the simulation
DEAgent(ModelDisplay modelDisplayer, Simulation thisSim)
          Constructor that takes the model display (the original position will be randomly assigned) and the simulation
 
Method Summary
 void init(Simulation thisSim)
          Method to initialize the discrete event agent
 boolean isBlocked()
          Method to check if we are blocked?
 boolean isReady(Resource res)
          Method to check if we ready to be unlocked? return true if ready else false
 void processEvent(int message)
          Process an event.
 void unblocked(Resource resource)
          I've been unblocked!
 double validTime(double delay)
          Method to return the current simulation time if the passed delay is negative or the time + the passed delay
 void waitFor(Resource resource)
          Block myself for the input resource
 
Methods inherited from class Agent
act, act, countInRange, die, getClosest, getPicture, getSimulation, getSpeed, setPicture, setSpeed
 
Methods inherited from class SimpleTurtle
backward, backward, clearPath, drawInfoString, drop, forward, forward, getBodyColor, getDistance, getHeading, getHeight, getInfoColor, getModelDisplay, getName, getPen, getPenColor, getPenWidth, getShellColor, getShowInfo, getWidth, getXPos, getYPos, hide, isPenDown, isVisible, moveTo, paintComponent, penDown, penUp, setBodyColor, setColor, setHeading, setHeight, setInfoColor, setModelDisplay, setName, setPen, setPenColor, setPenDown, setPenWidth, setShellColor, setShowInfo, setVisible, setWidth, show, toString, turn, turnLeft, turnRight, turnToFace, turnToFace, updateDisplay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DEAgent

public DEAgent(ModelDisplay modelDisplayer,
               Simulation thisSim)
Constructor that takes the model display (the original position will be randomly assigned) and the simulation

Parameters:
modelDisplayer - thing that displays the model
thisSim - my simulation

DEAgent

public DEAgent(int x,
               int y,
               ModelDisplay modelDisplayer,
               Simulation thisSim)
Constructor that takes the x and y, and a model display to draw it on, and the simulation

Parameters:
x - the starting x position
y - the starting y position
modelDisplayer - the thing that displays the model
thisSim - my simulation
Method Detail

init

public void init(Simulation thisSim)
Method to initialize the discrete event agent

Overrides:
init in class Agent
Parameters:
thisSim - the simulation

isBlocked

public boolean isBlocked()
Method to check if we are blocked?

Returns:
true if blocked else false

isReady

public boolean isReady(Resource res)
Method to check if we ready to be unlocked? return true if ready else false


validTime

public double validTime(double delay)
Method to return the current simulation time if the passed delay is negative or the time + the passed delay

Parameters:
delay - the amount of time for the delay
Returns:
either the current time plus the delay if the delay was positive or the current time

waitFor

public void waitFor(Resource resource)
Block myself for the input resource

Parameters:
resource - the desired resource

unblocked

public void unblocked(Resource resource)
I've been unblocked!

Parameters:
resource - the desired resource

processEvent

public void processEvent(int message)
Process an event. The default is to do nothing with it.

Parameters:
message - the message to process