Module org.example

Class Piece

java.lang.Object
cz.cvut.fel.pjv.model.Pieces.Piece
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Bishop, King, Knight, Pawn, Queen, Rook

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

    Fields
    Modifier and Type Field Description
    static java.lang.String BACK  
    static java.lang.String BLACK  
    static java.lang.String GREEN  
    static java.lang.String RESET  
    static java.lang.String WHITE  
  • Constructor Summary

    Constructors
    Constructor Description
    Piece​(boolean white)
    Create piece
    Piece​(Piece piece)  
  • Method Summary

    Modifier and Type Method Description
    abstract boolean canMove​(Board board, Spot start, Spot end)
    Methode to validate if the move is possible.
    abstract java.lang.String getPieceSymbol()
    Method to get a symbol of the piece for print on board.
    boolean isChecking​(Board board, Spot position, java.lang.Boolean playerColor)  
    boolean isKilled()  
    boolean isKingInDanger​(Board board, Spot piecePosition, java.lang.Boolean kingColor)
    Check if the king is in the danger after the user move.
    boolean isWhite()  
    void setKilled​(boolean killed)  
    void setWhite​(boolean white)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Piece

      public Piece​(boolean white)
      Create piece
      Parameters:
      white -
    • Piece

      public Piece​(Piece piece)
  • Method Details

    • isKilled

      public boolean isKilled()
    • isWhite

      public boolean isWhite()
    • setKilled

      public void setKilled​(boolean killed)
    • setWhite

      public void setWhite​(boolean white)
    • canMove

      public abstract boolean canMove​(Board board, Spot start, Spot end) throws java.lang.Exception
      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.Exception
      Check 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: