Class Light

java.lang.Object
  |
  +--Light
Direct Known Subclasses:
squareLight

public class Light
extends java.lang.Object

Light class allows us to represent a circular light in a graphical context. Lights have one color when on and another when off. Lights know their coordiantes where they need to be drawn. They begin in their off color (lightGray), but each call to their switch method switches them from on to off or from off to on. A Light object is only drawn when its draw(Graphic) method is called from a paint() method.


Constructor Summary
Light(int size, java.awt.Color onColor, int x, int y)
          Construct a new Light with provided info.
 
Method Summary
 void draw(java.awt.Graphics g)
          Draw the light using g
 boolean on()
          Return Light's on/off status.
 java.awt.Color onColor()
          Return Light's on color.
 int size()
          Return Light's size.
 void switchLight()
          Turn a light on, if off, and off, if on.
 int x()
          Return Light's x-coordinate.
 int y()
          Return Light's y-coordinate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Light

public Light(int size,
             java.awt.Color onColor,
             int x,
             int y)
Construct a new Light with provided info.

Method Detail

switchLight

public void switchLight()
Turn a light on, if off, and off, if on.


draw

public void draw(java.awt.Graphics g)
Draw the light using g


on

public boolean on()
Return Light's on/off status.


onColor

public java.awt.Color onColor()
Return Light's on color.


size

public int size()
Return Light's size.


x

public int x()
Return Light's x-coordinate.


y

public int y()
Return Light's y-coordinate.