Package threeChess

Class Piece


  • public class Piece
    extends java.lang.Object
    A specific piece on the board. Each piece has a Colour and a Type, and is immutable. Not an enum so we can have identical, but non-equal pieces, such as pawns.
    • Constructor Detail

      • Piece

        public Piece​(PieceType type,
                     Colour colour)
        Constructs a piece of the given type and colour.
        Parameters:
        type - the type of the piece
        colour - the colour of the piece
    • Method Detail

      • getType

        public PieceType getType()
        Returns:
        the type of the piece
      • getValue

        public int getValue()
        Returns:
        the value of the piece
      • getColour

        public Colour getColour()
        Returns:
        the colour of the piece
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of the piece