Class Distributor

java.lang.Object
  extended bySimpleTurtle
      extended byTurtle
          extended byAgent
              extended byDEAgent
                  extended byDistributor

public class Distributor
extends DEAgent

Distributor -- takes orders from Market to Warehouse, fills them, and returns with product.


Field Summary
(package private)  int amountOrdered
          AmountOrdered so-far
static int MARKET_ARRIVE
           
static int MARKET_LEAVE
           
static int WAREHOUSE_ARRIVE
           
 
Fields inherited from class DEAgent
blocked
 
Fields inherited from class Agent
MAXSPEED, myPict, PROB_OF_STAY, randNumGen, simulation, speed
 
Constructor Summary
Distributor(int x, int y, ModelDisplay modelDisplayer, Simulation thisSim)
          Constructor that takes the x and y and a model display to draw it on
Distributor(ModelDisplay modelDisplayer, Simulation thisSim)
          Constructor that takes the model display (the original position will be randomly assigned)
 
Method Summary
 void init(Simulation thisSim)
          Initialize a distributor.
 boolean isReady(Resource res)
          Are we ready to be unlocked?
 int newOrders()
           
 void processEvent(int message)
          Process an event.
 double timeToDeliver()
           
 double tripTime()
           
 void unblocked(Resource resource)
          I've been unblocked!
 
Methods inherited from class DEAgent
isBlocked, validTime, waitFor
 
Methods inherited from class Agent
act, act, countInRange, die, getClosest, getSimulation, getSpeed, setSpeed
 
Methods inherited from class Turtle
square
 
Methods inherited from class SimpleTurtle
backward, drawInfoString, drop, forward, forward, getBodyColor, getDistance, getHeading, getInfoColor, getModelDisplay, getName, getPen, getPenColor, getPenWidth, getPicture, getShellColor, getShowInfo, getXPos, getYPos, hide, isPenDown, isVisible, moveTo, paintComponent, penDown, penUp, setBodyColor, setColor, setHeading, setInfoColor, setModelDisplay, setName, setPen, setPenColor, setPenDown, setPenWidth, setPicture, setShellColor, setShowInfo, setVisible, 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
 

Field Detail

MARKET_ARRIVE

public static final int MARKET_ARRIVE
See Also:
Constant Field Values

MARKET_LEAVE

public static final int MARKET_LEAVE
See Also:
Constant Field Values

WAREHOUSE_ARRIVE

public static final int WAREHOUSE_ARRIVE
See Also:
Constant Field Values

amountOrdered

int amountOrdered
AmountOrdered so-far

Constructor Detail

Distributor

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

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

Distributor

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

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

newOrders

public int newOrders()

timeToDeliver

public double timeToDeliver()

tripTime

public double tripTime()

init

public void init(Simulation thisSim)
Initialize a distributor. Start in the market, taking orders, then schedule arrival at the warehouse.

Overrides:
init in class DEAgent

isReady

public boolean isReady(Resource res)
Are we ready to be unlocked?

Overrides:
isReady in class DEAgent

unblocked

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

Overrides:
unblocked in class DEAgent
Parameters:
resource - the desired resource

processEvent

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

Overrides:
processEvent in class DEAgent