framework
Class Move

java.lang.Object
  extended by framework.Move
Direct Known Subclasses:
BridgeMove, WaterJugMove

public abstract class Move
extends java.lang.Object

This abstract class represents a move in a problem solving domain. It provides a constructor and accessor for a move's name, but extending classes must provide code for actually performing moves. Extending classes need not have an instance field for the move name, as it is inherited from this class. Extending classes must access the move name through this class's getMoveName() method.


Constructor Summary
Move(java.lang.String moveName)
          Creates a problem move, storing the move name.
 
Method Summary
abstract  State doMove(State state)
          Performs this move on a given state.
 java.lang.String getMoveName()
          Accessor for this move's name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Move

public Move(java.lang.String moveName)
Creates a problem move, storing the move name. It is a precondition that the move name be valid for the underlying problem. Extending class constructors must call this constructor first using super.

Parameters:
moveName - the user command for this move.
Method Detail

doMove

public abstract State doMove(State state)
Performs this move on a given state. Extending classes must override this method. Note also that overriding methods should cast the State argument to the appropriate specific class type before using it. Depending on the move name for this state, this method attempts to create a new state that is the result of applying the move to the given state. If the move cannot be performed for whatever reason, null is returned. Otherwise the resulting NEW state is returned. Note that the argument state is not altered.

Parameters:
state - an existing state
Returns:
a new state resulting from the move (might be null)

getMoveName

public java.lang.String getMoveName()
Accessor for this move's name.

Returns:
the name of this move