becker.robots
Class Streetlight

java.lang.Object
  extended by becker.robots.Sim
      extended by becker.robots.Thing
          extended by becker.robots.Light
              extended by becker.robots.Streetlight

public class Streetlight
extends Light

A Streetlight is a kind of Light that lights an intersection. Like all lights, it can be turned on and off. A streetlight cannot be moved by a robot.

Author:
Byron Weber Becker

Constructor Summary
Streetlight(City city, int street, int avenue, Direction corner)
          Construct a new streetlight.
Streetlight(City city, int street, int avenue, Direction corner, boolean isOn)
          Construct a new streetlight.
 
Method Summary
protected  void save(String indent, PrintWriter out)
          Save a representation of this intersection to an output stream.
 String toString()
          Print this object represented as a string.
 void turnOff()
          Turn the streetlight off.
 void turnOn()
          Turn the streetlight on.
 
Methods inherited from class becker.robots.Light
isOn
 
Methods inherited from class becker.robots.Thing
blocksIntersectionEntry, blocksIntersectionExit, canBeCarried, getIntersection, setBlocksEntry, setBlocksEntry, setBlocksExit, setBlocksExit, setCanBeCarried
 
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
 

Constructor Detail

Streetlight

public Streetlight(City city,
                   int street,
                   int avenue,
                   Direction corner,
                   boolean isOn)
Construct a new streetlight.

Parameters:
city - The city in which the streetlight will exist.
street - The streetlight's initial street within the city.
avenue - The streetlight's initial avenue within the city.
corner - The corner of the intersection occupied by the streetlight. One of {Direction.NORTHEAST, SOUTHEAST, SOUTHWEST, NORTHWEST}.
isOn - True if the streetlight is on when constructed.

Streetlight

public Streetlight(City city,
                   int street,
                   int avenue,
                   Direction corner)
Construct a new streetlight. The light is initially off.

Parameters:
city - The city in which the streetlight will exist.
street - The streetlight's initial street within the city.
avenue - The streetlight's initial avenue within the city.
corner - The corner of the intersection occupied by the streetlight. One of {Direction.NORTHEAST, SOUTHEAST, SOUTHWEST, NORTHWEST}.
Method Detail

turnOn

public void turnOn()
Turn the streetlight on.

Overrides:
turnOn in class Light

turnOff

public void turnOff()
Turn the streetlight off.

Overrides:
turnOff in class Light

save

protected void save(String indent,
                    PrintWriter out)
Save a representation of this intersection to an output stream.

Overrides:
save in class Thing
Parameters:
indent - the indentation, for formatting purposes
out - the output stream

toString

public String toString()
Print this object represented as a string.

Overrides:
toString in class Thing