Class StudentDriver

java.lang.Object
  extended by becker.robots.Sim
      extended by becker.robots.Robot
          extended by becker.robots.RobotSE
              extended by StudentDriver
All Implemented Interfaces:
becker.robots.IColor, becker.robots.ILabel, java.lang.Runnable

public class StudentDriver
extends becker.robots.RobotSE
implements java.lang.Runnable

This class provides support for the Drivers' Ed project found here.

Author:
Chris Darcy

Constructor Summary
StudentDriver(Annex c, int s, int a, becker.robots.Direction d, int f, double speed, java.lang.String name, java.lang.String imageFile)
          The constructor passes on the first five parameters to its superclass before preserving the Annex object in one of its instance fields, setting its speed (in moves per second) to the value of the sixth parameter, preserving the driver's name in another instance field, before finally setting its icon to the CarIcon using the supplied image file name.
 
Method Summary
protected  becker.robots.Thing makeThing(int n, int total)
          In order to ensure the liters of fuel are depicted as Things with a dark gray CircleIcon of size 0.05 it is necessary to override Thing's makeThing(int n, int total) method.
 void move()
          Drops a liter of fuel on each intersection prior to moving to the next intersection.
 void run()
          Called by the Thread object.
 
Methods inherited from class becker.robots.RobotSE
countThingsInBackpack, isBesideThing, isFacingEast, isFacingNorth, isFacingSouth, isFacingWest, move, pickAllThings, pickAllThings, pickThing, pickThing, putAllThings, putAllThings, putThing, putThing, save, turnAround, turnLeft, turnRight, turnRight
 
Methods inherited from class becker.robots.Robot
breakRobot, canPickThing, countThingsInBackpack, examineLights, examineRobots, examineThings, examineThings, frontIsClear, getAvenue, getDirection, getIntersection, getLabel, getSpeed, getStreet, getTransparency, pickThing, putThing, setLabel, setSpeed, setTransparency, toString, turnLeft
 
Methods inherited from class becker.robots.Sim
getCity, getColor, getIcon, keyTyped, notifyObservers, notifyObservers, setColor, setIcon
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface becker.robots.IColor
getColor, setColor
 

Constructor Detail

StudentDriver

public StudentDriver(Annex c,
                     int s,
                     int a,
                     becker.robots.Direction d,
                     int f,
                     double speed,
                     java.lang.String name,
                     java.lang.String imageFile)
The constructor passes on the first five parameters to its superclass before preserving the Annex object in one of its instance fields, setting its speed (in moves per second) to the value of the sixth parameter, preserving the driver's name in another instance field, before finally setting its icon to the CarIcon using the supplied image file name.

Parameters:
c - the Annex object
s - the initial street
a - the initial avenue
d - the initial direction
f - the number of liters of fuel (Things)
speed - the initial speed to be assigned to the object
name - the name of the Georgian driver
imageFile - the file name of the Icon for this StudentDriver object
Method Detail

makeThing

protected becker.robots.Thing makeThing(int n,
                                        int total)
In order to ensure the liters of fuel are depicted as Things with a dark gray CircleIcon of size 0.05 it is necessary to override Thing's makeThing(int n, int total) method.

Overrides:
makeThing in class becker.robots.Robot

run

public void run()
Called by the Thread object. A Student Driver object moves randomly about the annex. At each intersection it must determine whether there is a traffic light at the intersection. If there is, it must wait until it turns green before continuing. In deciding which direction to move in, the object must first obtain a list (array) of possible directions from a method within the Annex class. A random direction is chosen from the list to which the object faces. Prior to the actual move the object drops a liter of fuel. Moving continues as long as it has fuel.

Specified by:
run in interface java.lang.Runnable

move

public void move()
Drops a liter of fuel on each intersection prior to moving to the next intersection.

Overrides:
move in class becker.robots.Robot