Package jadex.web.examples.puzzle
Class Board
- java.lang.Object
- 
- jadex.web.examples.puzzle.Board
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 
 public class Board extends java.lang.Object implements java.io.Serializable, java.lang.CloneableThe board containing places, pieces and played moves.- See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected Positionhole_posThe hole position.protected java.util.List<Move>movesThe moves.PropertyChangeSupportpcsThe helper object for bean events.protected java.util.Map<Position,Piece>piecesThe pieces.protected intsizeThe size.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener listener)Add a PropertyChangeListener to the listener list.java.lang.Objectclone()Clone the board.java.util.List<Piece>getCurrentPosition()Get the current board position.MovegetLastMove()Get all moves made so far.java.util.List<Move>getMoves()Get all moves made so far.PiecegetPiece(Position pos)Get a piece for a location.java.util.List<Move>getPossibleMoves()Get possible moves.intgetSize()Get the board size.booleanisFreePosition(Position pos)Test if aposition is free.protected booleanisPossibleMove(Move move)Get a piece for a location.booleanisSolution()Test if it is a solution.static voidmain(java.lang.String[] args)Main for testing.booleanmove(Move move)Do a move.voidremovePropertyChangeListener(PropertyChangeListener listener)Remove a PropertyChangeListener from the listener list.booleantakeback()Takeback a move.java.lang.StringtoString()Get the string representation.booleanwasLastMoveWhite()Test if the last move was with a white piece.
 
- 
- 
- 
Field Detail- 
movesprotected java.util.List<Move> moves The moves.
 - 
sizeprotected int size The size.
 - 
hole_posprotected Position hole_pos The hole position.
 - 
pcspublic PropertyChangeSupport pcs The helper object for bean events.
 
- 
 - 
Method Detail- 
getPossibleMovespublic java.util.List<Move> getPossibleMoves() Get possible moves.- Returns:
- Get all possible move.
 
 - 
movepublic boolean move(Move move) Do a move.- Parameters:
- move- The move.
 
 - 
takebackpublic boolean takeback() Takeback a move.
 - 
isSolutionpublic boolean isSolution() Test if it is a solution.- Returns:
- True, if solution.
 
 - 
getMovespublic java.util.List<Move> getMoves() Get all moves made so far.
 - 
getLastMovepublic Move getLastMove() Get all moves made so far.
 - 
wasLastMoveWhitepublic boolean wasLastMoveWhite() Test if the last move was with a white piece. When no move was made, it return true.- Returns:
- True, is last move was with white piece.
 
 - 
isFreePositionpublic boolean isFreePosition(Position pos) Test if aposition is free.
 - 
isPossibleMoveprotected boolean isPossibleMove(Move move) Get a piece for a location.
 - 
getSizepublic int getSize() Get the board size.
 - 
getCurrentPositionpublic java.util.List<Piece> getCurrentPosition() Get the current board position.
 - 
toStringpublic java.lang.String toString() Get the string representation.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- The string representation.
 
 - 
clonepublic java.lang.Object clone() Clone the board.- Overrides:
- clonein class- java.lang.Object
- Returns:
- The clone.
 
 - 
addPropertyChangeListenerpublic void addPropertyChangeListener(PropertyChangeListener listener) Add a PropertyChangeListener to the listener list. The listener is registered for all properties.- Parameters:
- listener- The PropertyChangeListener to be added.
 
 - 
removePropertyChangeListenerpublic void removePropertyChangeListener(PropertyChangeListener listener) Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.- Parameters:
- listener- The PropertyChangeListener to be removed.
 
 - 
mainpublic static void main(java.lang.String[] args) Main for testing.
 
- 
 
-