waterjug
Class WaterJugState
java.lang.Object
waterjug.WaterJugState
- All Implemented Interfaces:
- State
public class WaterJugState
- extends java.lang.Object
- implements State
This class represents states of the Water Jug problem.
It creates new water jug states, tests states for equality,
and produces string representations of them.
Note that this class implements the State interface
and therefore imports framework.State.
Method Summary |
boolean |
equals(java.lang.Object other)
Tests for equality between this state and the argument state. |
java.lang.String |
toString()
Creates a primitive, non-GUI representation of this WaterJugState object. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
WaterJugState
public WaterJugState()
equals
public boolean equals(java.lang.Object other)
- Tests for equality between this state and the argument state.
Two states are equal if the X jugs have the same amount of water
and the Y jugs have the same amount of water.
- Specified by:
equals
in interface State
- Overrides:
equals
in class java.lang.Object
- Parameters:
other
- the state to test against this state
- Returns:
- whether the states are equal
toString
public java.lang.String toString()
- Creates a primitive, non-GUI representation of this WaterJugState object.
- Specified by:
toString
in interface State
- Overrides:
toString
in class java.lang.Object
- Returns:
- the string representation of this water jug state