becker.robots
Class Flasher

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

public class Flasher
extends Light

A flasher is commonly used to mark construction hazards on streets and avenues. Flashers are small enough for a robot to pick up and carry. They do not obstruct the movement of robots. Like all lights, they can be turned on and off. Unlike some kinds of lights, when flashers are "on" their lights cycle on and off. When flashers are turned "off" their lights stay off.

Author:
Byron Weber Becker

Constructor Summary
Flasher(City city, int avenue, int street)
          Construct a new flasher, initially turned off.
Flasher(City city, int avenue, int street, boolean isOn)
          Construct a new flasher.
Flasher(Robot heldBy)
          Construct a new flasher held by a robot.
 
Method Summary
protected  void save(String indent, PrintWriter out)
          Save a representation of this flasher to an output stream.
 String toString()
          Print this object represented as a string.
 void turnOff()
          Turn the flasher off.
 void turnOn()
          Turn the flasher on so that it begins to flash.
 
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

Flasher

public Flasher(City city,
               int avenue,
               int street)
Construct a new flasher, initially turned off.

Parameters:
city - The city in which the flasher will exist.
avenue - The flasher's initial avenue within the city.
street - The flasher's initial street within the city.

Flasher

public Flasher(City city,
               int avenue,
               int street,
               boolean isOn)
Construct a new flasher.

Parameters:
city - The city in which the flasher will exist.
avenue - The flasher's initial avenue within the city.
street - The flasher's initial street within the city.
isOn - True if the flasher is on; false otherwise.

Flasher

public Flasher(Robot heldBy)
Construct a new flasher held by a robot.

Parameters:
heldBy - the robot holding the flasher.
Method Detail

turnOn

public void turnOn()
Turn the flasher on so that it begins to flash.

Overrides:
turnOn in class Light

turnOff

public void turnOff()
Turn the flasher off.

Overrides:
turnOff in class Light

save

protected void save(String indent,
                    PrintWriter out)
Save a representation of this flasher 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