|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object becker.robots.Sim becker.robots.Thing becker.robots.Light
public abstract class Light
A light is a kind of thing that can be turned on to make it brighter
and turned off to make it darker. Some lights can be moved
(Flasher
) while others can't (Streetlight
).
The Light
class itself is abstract meaning programmers
cannot construct an instance of Light
. It must be extended
to create a class that can be instantiated. This class does
define a common interface for all lights so that that any light may
be turned on or off without knowing what specific kind of light it is
(polymorphism).
Constructor Summary | |
---|---|
Light(City aCity,
int aStreet,
int anAvenue)
Construct a new light with the same default appearance as a Thing. |
|
Light(City aCity,
int aStreet,
int anAvenue,
Direction orientation,
boolean canBeMoved,
Icon anIcon)
Construct a new light. |
|
Light(Robot heldBy)
Construct a new Light held by a robot. |
Method Summary | |
---|---|
boolean |
isOn()
Determine whether or not the light is turned on. |
void |
turnOff()
Turn the light off. |
void |
turnOn()
Turn the light on. |
Methods inherited from class becker.robots.Thing |
---|
blocksIntersectionEntry, blocksIntersectionExit, canBeCarried, getIntersection, save, setBlocksEntry, setBlocksEntry, setBlocksExit, setBlocksExit, setCanBeCarried, toString |
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 |
---|
public Light(City aCity, int aStreet, int anAvenue)
aCity
- The city in which the light will exist.aStreet
- The light's initial street within the city.anAvenue
- The light's initial avenue within the city.public Light(City aCity, int aStreet, int anAvenue, Direction orientation, boolean canBeMoved, Icon anIcon)
aCity
- The city in which the light will exist.aStreet
- The light's initial street within the city.anAvenue
- The light's initial avenue within the city.orientation
- The light's initial orientation. A streetlight,
for instance, uses this to determine on which corner of the intersection
it appears. One of {Direction
.NORTH, EAST, SOUTH, WEST,
NORTHWEST, NORTHEAST, SOUTHWEST, SOUTHEAST}.canBeMoved
- Specifies whether or not the light can be moved
by a robot.anIcon
- The icon to use to display this light.public Light(Robot heldBy)
heldBy
- the robot holding the light.Method Detail |
---|
public void turnOn()
public void turnOff()
public boolean isOn()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |