java.lang.Object
cz.cvut.fel.pjv.model.Pieces.Piece
- All Implemented Interfaces:
java.io.Serializable
public abstract class Piece
extends java.lang.Object
implements java.io.Serializable
Abstract class for define pieces & support methods for piece
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description abstract booleancanMove(Board board, Spot start, Spot end)Methode to validate if the move is possible.abstract java.lang.StringgetPieceSymbol()Method to get a symbol of the piece for print on board.booleanisChecking(Board board, Spot position, java.lang.Boolean playerColor)booleanisKilled()booleanisKingInDanger(Board board, Spot piecePosition, java.lang.Boolean kingColor)Check if the king is in the danger after the user move.booleanisWhite()voidsetKilled(boolean killed)voidsetWhite(boolean white)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
BLACK
public static final java.lang.String BLACK- See Also:
- Constant Field Values
-
WHITE
public static final java.lang.String WHITE- See Also:
- Constant Field Values
-
GREEN
public static final java.lang.String GREEN- See Also:
- Constant Field Values
-
RESET
public static final java.lang.String RESET- See Also:
- Constant Field Values
-
BACK
public static final java.lang.String BACK- See Also:
- Constant Field Values
-
-
Constructor Details
-
Piece
public Piece(boolean white)Create piece- Parameters:
white-
-
Piece
-
-
Method Details
-
isKilled
public boolean isKilled() -
isWhite
public boolean isWhite() -
setKilled
public void setKilled(boolean killed) -
setWhite
public void setWhite(boolean white) -
canMove
Methode to validate if the move is possible.- Parameters:
board-start-end-- Returns:
- Throws:
java.lang.Exception
-
isKingInDanger
public boolean isKingInDanger(Board board, Spot piecePosition, java.lang.Boolean kingColor) throws java.lang.ExceptionCheck if the king is in the danger after the user move.- Parameters:
board-piecePosition-kingColor-- Returns:
- Throws:
java.lang.Exception
-
isChecking
public boolean isChecking(Board board, Spot position, java.lang.Boolean playerColor) throws java.lang.Exception- Throws:
java.lang.Exception
-
getPieceSymbol
public abstract java.lang.String getPieceSymbol()Method to get a symbol of the piece for print on board.- Returns:
-