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 Piece
black_piece
protected java.util.ArrayList
moves
SimplePropertyChangeSupport
pcs
protected Piece
white_piece
-
Constructor Summary
Constructors Constructor Description JackBoard()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.java.util.List
getCurrentPosition()
Get the current board position.Move
getLastMove()
Get all moves made so far.java.util.List
getMoves()
Get all moves made so far.Piece
getPiece(Position pos)
Get a piece for a location.java.util.List
getPossibleMoves()
Get possible moves.int
getSize()
Get the board size.boolean
isFreePosition(Position pos)
Test if a position is free.boolean
isSolution()
Test if it is a solution.boolean
move(Move move)
Do a move.void
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.boolean
takeback()
Takeback a move.boolean
wasLastMoveWhite()
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:
getPossibleMoves
in 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:
isSolution
in 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:
getLastMove
in 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:
wasLastMoveWhite
in interfaceIBoard
- Returns:
- True, is last move was with white piece.
-
getCurrentPosition
public java.util.List getCurrentPosition()
Get the current board position.- Specified by:
getCurrentPosition
in interfaceIBoard
-
isFreePosition
public boolean isFreePosition(Position pos)
Test if a position is free.- Specified by:
isFreePosition
in interfaceIBoard
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Specified by:
addPropertyChangeListener
in 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:
removePropertyChangeListener
in interfaceIBoard
- Parameters:
listener
- The PropertyChangeListener to be removed.
-
-