Package api
Class MoveRecord
- java.lang.Object
-
- api.MoveRecord
-
public class MoveRecord extends java.lang.ObjectA MoveRecord encapsulates a State along with information about how it might have been shifted or modified during a move in the game.- Author:
- smkautz
-
-
Constructor Summary
Constructors Constructor Description MoveRecord(State givenState, int currentIndex)Constructs a MoveRecord from the given State and index.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetIndex()Returns the index in this MoveRecord.intgetMovedTo()Returns the (possibly) new index for this MoveRecord's cell.StategetState()Returns the state in this MoveRecord.booleanisClosed()Determines whether this state is an open gate that was closed by a move.booleanisDisappeared()Determines whether this state was deleted.booleanisMoved()Determines whether this cell has been given a new index.voidsetClosed()Sets the closed status of this MoveRecord.voidsetDisappeared()Sets the disappeared status of this MoveRecord.voidsetMovedToIndex(int newIndex)Sets the new index to indicate a state moved to a new location within a state sequence.java.lang.StringtoString()Returns a string representation of this MoveRecord.
-
-
-
Constructor Detail
-
MoveRecord
public MoveRecord(State givenState, int currentIndex)
Constructs a MoveRecord from the given State and index. Normally the index is the same as the cell's array index within a valid state sequence. The movedTo index is initially the same as the given index and the disappeared status is false. Index 0 is always the player's initial location.- Parameters:
givenState- State for this MoveRecordcurrentIndex- index for this MoveRecord
-
-
Method Detail
-
getState
public State getState()
Returns the state in this MoveRecord.- Returns:
- state in this MoveRecord
-
getIndex
public int getIndex()
Returns the index in this MoveRecord.- Returns:
- index in this MoveRecord
-
setMovedToIndex
public void setMovedToIndex(int newIndex)
Sets the new index to indicate a state moved to a new location within a state sequence. In the case of a cell containing the player, the new index indicates the new location of the player in the sequence.- Parameters:
newIndex- new index for the current cell (or player)
-
getMovedTo
public int getMovedTo()
Returns the (possibly) new index for this MoveRecord's cell.- Returns:
- new index for this MoveRecord's cell
-
isMoved
public boolean isMoved()
Determines whether this cell has been given a new index.- Returns:
- true if the new index differs from the original index
-
isDisappeared
public boolean isDisappeared()
Determines whether this state was deleted.- Returns:
- true if this state was deleted, false otherwise
-
setDisappeared
public void setDisappeared()
Sets the disappeared status of this MoveRecord.
-
isClosed
public boolean isClosed()
Determines whether this state is an open gate that was closed by a move.- Returns:
- true if this state was closed
-
setClosed
public void setClosed()
Sets the closed status of this MoveRecord.
-
toString
public java.lang.String toString()
Returns a string representation of this MoveRecord.- Overrides:
toStringin classjava.lang.Object
-
-