public class LightObserver
extends java.lang.Object
Constructor and Description |
---|
LightObserver(Lights lights)
This constructor creates a new LightOberserver storing the current and
last state of a given group of lights.
|
Modifier and Type | Method and Description |
---|---|
LightState |
getCurrentState()
This funtion returns the current state of the observed group of lights.
|
LightState |
getLastState()
This funtion returns the last state of the observed group of lights (i.e.
|
Lights |
getLights()
This function returns the group of lights observed.
|
java.util.Stack<LightState> |
getStates()
This function returns a stack of all known states, beginning with the
current one.
|
void |
restore()
This function removes the youngest state from the stack and restores it
to the group of lights observerd by this instance.
|
java.lang.String |
toString()
This function describes the objet as a string.
|
public LightObserver(Lights lights)
lights
- the group of lights to observepublic LightState getCurrentState()
public java.util.Stack<LightState> getStates()
public LightState getLastState() throws java.util.EmptyStackException
java.util.EmptyStackException
- if the stack of states is emptypublic void restore() throws java.io.IOException, java.util.EmptyStackException
java.io.IOException
- if the message to the WiFiBox could not be sentjava.util.EmptyStackException
- if the stack of states is emptypublic Lights getLights()
public java.lang.String toString()
toString
in class java.lang.Object