Class Distributor

java.lang.Object
  extended by SimpleTurtle
      extended by Turtle
          extended by Agent
              extended by DEAgent
                  extended by Distributor

public class Distributor
extends DEAgent

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

Author:
Mark Guzdial, Barb Ericson

Field Summary
static int MARKET_ARRIVE
          message that means things have arrived at the market
static int MARKET_LEAVE
          message that means the goods have left the market
static int WAREHOUSE_ARRIVE
          message that means items arrived at the warehouse
 
Fields inherited from class Agent
MAX_SPEED, PROB_OF_STAY, randNumGen
 
Constructor Summary
Distributor(int x, int y, ModelDisplay modelDisplayer, Simulation thisSim)
          Constructor that takes the x and y, a model display to draw it on, and the simulation
Distributor(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)
          Initialize a distributor.
 boolean isReady(Resource res)
          Method to check if we are we ready to be unlocked?
 int newOrders()
          return the number of new orders
 void processEvent(int message)
          Process an event.
 double timeToDeliver()
          return the time to deliver
 double tripTime()
          return the trip time
 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, 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
 

Field Detail

MARKET_ARRIVE

public static final int MARKET_ARRIVE
message that means things have arrived at the market

See Also:
Constant Field Values

MARKET_LEAVE

public static final int MARKET_LEAVE
message that means the goods have left the market

See Also:
Constant Field Values

WAREHOUSE_ARRIVE

public static final int WAREHOUSE_ARRIVE
message that means items arrived at the warehouse

See Also:
Constant Field Values
Constructor Detail

Distributor

public Distributor(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

Distributor

public Distributor(int x,
                   int y,
                   ModelDisplay modelDisplayer,
                   Simulation thisSim)
Constructor that takes the x and y, 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

newOrders

public int newOrders()
return the number of new orders

Returns:
the number of new orders

timeToDeliver

public double timeToDeliver()
return the time to deliver

Returns:
the time to deliver

tripTime

public double tripTime()
return the trip time

Returns:
the trip time

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
Parameters:
thisSim - the simulation

isReady

public boolean isReady(Resource res)
Method to check if we are we ready to be unlocked?

Overrides:
isReady in class DEAgent
Parameters:
res - the resource
Returns:
true if ready else false

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
Parameters:
message - the message to process