Class Truck

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

public class Truck
extends DEAgent

Truck -- delivers product from the Factory to the Warehouse.

Author:
Mark Guzdial, Barb Ericson

Field Summary
static int FACTORY_ARRIVE
          an arrive at factory event
static int WAREHOUSE_ARRIVE
          an arrive at warehouse event
 
Fields inherited from class Agent
MAX_SPEED, PROB_OF_STAY, randNumGen
 
Constructor Summary
Truck(int x, int y, ModelDisplay modelDisplayer, Simulation thisSim)
          Constructor that takes the x and y, a model display to draw it on, and a simulation
Truck(ModelDisplay modelDisplayer, Simulation thisSim)
          Constructor that takes the model display (the original position will be randomly assigned) and a simulation
 
Method Summary
 void init(Simulation thisSim)
          Set up the truck Start out at the factory
 int newLoad()
          A method to create a new load.
 void processEvent(int message)
          Process an event.
 double tripTime()
          Calculate and return the total trip time
 
Methods inherited from class DEAgent
isBlocked, isReady, unblocked, 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

FACTORY_ARRIVE

public static final int FACTORY_ARRIVE
an arrive at factory event

See Also:
Constant Field Values

WAREHOUSE_ARRIVE

public static final int WAREHOUSE_ARRIVE
an arrive at warehouse event

See Also:
Constant Field Values
Constructor Detail

Truck

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

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

Truck

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

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

newLoad

public int newLoad()
A method to create a new load. The returned amount will be between 10 and 20 on a uniform distribution


tripTime

public double tripTime()
Calculate and return the total trip time

Returns:
the total time of the trip in days

init

public void init(Simulation thisSim)
Set up the truck Start out at the factory

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

processEvent

public void processEvent(int message)
Process an event.

Overrides:
processEvent in class DEAgent
Parameters:
message - the type of event