|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.problems.fifteenpuzzle.SlideMove
public class SlideMove
Slide a numbered tile from (c,r) to (c', r').
Field Summary | |
---|---|
int |
fromC
column coordinate of the move's source. |
int |
fromR
row coordinate of the move's source. |
int |
tile
tile being moved. |
int |
toC
column coordinate of the move's destination. |
int |
toR
row coordinate of the move's destination. |
Constructor Summary | |
---|---|
SlideMove(int tile,
int fromC,
int fromR,
int toC,
int toR)
Move from (fromC, fromR) -> (toC, toR) |
Method Summary | |
---|---|
boolean |
execute(INode staten)
Execute the move on the given board state. |
boolean |
isValid(INode staten)
Determine if move is valid for the given state. |
java.lang.String |
toString()
Reasonable implementation. |
boolean |
undo(INode staten)
Assume move had been valid, so the undo is a straightforward swap. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final int tile
public final int fromC
public final int fromR
public final int toC
public final int toR
Constructor Detail |
---|
public SlideMove(int tile, int fromC, int fromR, int toC, int toR)
fromC
- column coordinate of the move's source.fromR
- row coordinate of the move's source.toC
- column coordinate of the move's destinationtoR
- row coordinate of the move's destinationMethod Detail |
---|
public boolean execute(INode staten)
execute
in interface IMove
staten
- state on which to execute the move.
java.lang.IllegalArgumentException
- if staten is not a FifteenPuzzleNodepublic boolean isValid(INode staten)
isValid
in interface IMove
staten
- state on which to execute the move.
java.lang.IllegalArgumentException
- if staten is not a FifteenPuzzleNodepublic boolean undo(INode staten)
undo
in interface IMove
staten
- state on which to execute the move.
java.lang.IllegalArgumentException
- if staten is not a FifteenPuzzleNodepublic java.lang.String toString()
toString
in class java.lang.Object
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |