Package jadex.bdi.examples.puzzle
Class JackBoard
- java.lang.Object
-
- jadex.bdi.examples.puzzle.JackBoard
-
- All Implemented Interfaces:
IBoard,java.io.Serializable
public class JackBoard extends java.lang.Object implements IBoard, java.io.Serializable
The View Board represents the puzzle board and the pegs.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Pieceblack_pieceprotected java.util.ArrayListmovesSimplePropertyChangeSupportpcsprotected Piecewhite_piece
-
Constructor Summary
Constructors Constructor Description JackBoard()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener listener)Add a PropertyChangeListener to the listener list.java.util.ListgetCurrentPosition()Get the current board position.MovegetLastMove()Get all moves made so far.java.util.ListgetMoves()Get all moves made so far.PiecegetPiece(Position pos)Get a piece for a location.java.util.ListgetPossibleMoves()Get possible moves.intgetSize()Get the board size.booleanisFreePosition(Position pos)Test if a position is free.booleanisSolution()Test if it is a solution.booleanmove(Move move)Do a move.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a PropertyChangeListener from the listener list.booleantakeback()Takeback a move.booleanwasLastMoveWhite()Test if the last move was with a white piece.
-
-
-
Field Detail
-
white_piece
protected Piece white_piece
-
black_piece
protected Piece black_piece
-
moves
protected java.util.ArrayList moves
-
pcs
public SimplePropertyChangeSupport pcs
-
-
Method Detail
-
getPossibleMoves
public java.util.List getPossibleMoves()
Get possible moves.- Specified by:
getPossibleMovesin interfaceIBoard- Returns:
- Get all possible move.
-
move
public boolean move(Move move)
Do a move.
-
isSolution
public boolean isSolution()
Test if it is a solution.- Specified by:
isSolutionin interfaceIBoard- Returns:
- True, if solution.
-
getMoves
public java.util.List getMoves()
Get all moves made so far.
-
getLastMove
public Move getLastMove()
Get all moves made so far.- Specified by:
getLastMovein interfaceIBoard
-
wasLastMoveWhite
public boolean wasLastMoveWhite()
Test if the last move was with a white piece. When no move was made, it return true.- Specified by:
wasLastMoveWhitein interfaceIBoard- Returns:
- True, is last move was with white piece.
-
getCurrentPosition
public java.util.List getCurrentPosition()
Get the current board position.- Specified by:
getCurrentPositionin interfaceIBoard
-
isFreePosition
public boolean isFreePosition(Position pos)
Test if a position is free.- Specified by:
isFreePositionin interfaceIBoard
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Specified by:
addPropertyChangeListenerin interfaceIBoard- Parameters:
listener- The PropertyChangeListener to be added.
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.- Specified by:
removePropertyChangeListenerin interfaceIBoard- Parameters:
listener- The PropertyChangeListener to be removed.
-
-