Class Annex

java.lang.Object
  extended by becker.robots.City
      extended by Annex

public class Annex
extends becker.robots.City

This class provides support for the Drivers' Ed project found here. A walled city environment is displayed with a Runnable TrafficLight object at one of the intersections.

Author:
Chris Darcy

Constructor Summary
Annex()
          The constructor loads its City configuration from the file Annex.txt, before turning on the Thing counts.
 
Method Summary
 becker.robots.Direction[] getPossibleDirections(StudentDriver student)
          This methods returns an array of possible directions available to a StudentDriver to pursue.
 boolean isTrafficLight(int s, int a)
          This predicate method can be called to determine if an intersection contains a TrafficLight object.
 boolean isTrafficLightRed(int s, int a)
          This predicate method can be called to determine if the TrafficLight object at this intersection is RED.
Precondition: There is a TrafficLight at this intersection.
protected  becker.robots.Intersection makeIntersection(int s, int a)
           
 
Methods inherited from class becker.robots.City
customizeIntersection, examineLights, examineRobots, examineThings, examineThings, getIntersection, getThingCountPredicate, isShowingThingCounts, keyTyped, save, setFrameTitle, setSize, setThingCountPredicate, showFrame, showThingCounts, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Annex

public Annex()
The constructor loads its City configuration from the file Annex.txt, before turning on the Thing counts. It instantiates a single instance of a Runnable TrafficLight, mounts it on a thread and launches the thread.

Method Detail

makeIntersection

protected becker.robots.Intersection makeIntersection(int s,
                                                      int a)
Overrides:
makeIntersection in class becker.robots.City

isTrafficLight

public boolean isTrafficLight(int s,
                              int a)
This predicate method can be called to determine if an intersection contains a TrafficLight object.

Parameters:
s - the street for which the request is made
a - the avenue for which the request is made
Returns:
true if the intersection contains a traffic light; false, otherwise

isTrafficLightRed

public boolean isTrafficLightRed(int s,
                                 int a)
This predicate method can be called to determine if the TrafficLight object at this intersection is RED.
Precondition: There is a TrafficLight at this intersection.

Parameters:
s - the street for which the request is made
a - the avenue for which the request is made
Returns:
true if the intersection contains a traffic light displaying the requested colour; false, otherwise

getPossibleDirections

public becker.robots.Direction[] getPossibleDirections(StudentDriver student)
This methods returns an array of possible directions available to a StudentDriver to pursue. Some directions are unavailable because they are blocked by walls and the opposite direction from which it is currently facing is also not an option (no U-turns!).

Parameters:
student - the StudentDriver object making the request
Returns:
an array of possible directions available to a StudentDriver to pursue