|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectks.common.model.Move
Represents a move within a solitaire game. This class is the abstract base class that provides the basic methods for representing any move within a solitaire game.
Each move has a set of parameters, each of which is a Model Element
object. These parameters can be set and retrieved using setParameter (String name,
Element e)
and getParameter (String name)
. Note that the name of the
parameter in these methods is a case-sensitive string.
For each type of move in a solitaire game, you must create a subclass of this class to represent that move type in the game.
The primary use of this class is to provide an interface for undoing moves. However, since the undo and do of moves are so closely related, this class is capable of handling both activities.
In general the move object is constructed and then validates the desired move to be made,
using suitable parameters as determined by the necessary subclass. Then
the Move object is pushed onto the stack of moves played by the Solitaire game. During
the Undo phase, each move is popped from this stack, and the effect is undone, using the undo()
method.
The Move object is responsible for refreshing and/or repainting affected widgets; This can
most rapidly be done using the refreshWidgets()
method.
The Move class is not responsible for the moves generated interactively by the user. In particular, Move objects are only instantiated once it is validated that a given move is allowed and has actually carried it out! This is an IMPORTANT POINT.
Creation date: (10/21/01 3:09:47 PM)
Method Summary | |
abstract boolean |
doMove(Solitaire game)
Each move knows how to execute itself. |
int |
getMoveType()
Return the move type. |
java.lang.String |
toString()
Produce a string representation of the move. |
abstract boolean |
undo(Solitaire game)
Each move knows how to undo itself. |
abstract boolean |
valid(Solitaire game)
Each move knows whether it is a valid move. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public abstract boolean doMove(Solitaire game)
Note: Each subclass must overrided this method and return true if the move is a valid move, false otherwise.
Creation date: (10/21/01 3:33:39 PM)
game
- the game being played.
public int getMoveType()
Creation date: (10/21/01 3:21:22 PM)
public java.lang.String toString()
Representation of the form:
[Move class name]
public abstract boolean undo(Solitaire game)
Note: Each subclass must overrided this method and return true if the move was successfully undone; false otherwise.
Creation date: (10/21/01 3:33:39 PM)
game
- the game being played.
public abstract boolean valid(Solitaire game)
Note: Each subclass must overrided this method and return true if the move is a valid move, false otherwise.
Creation date: (10/21/01 3:33:39 PM)
game
- the game being played.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |