java.lang.Object
castle.comp3021.assignment.protocol.Piece
Direct Known Subclasses:
Archer, Knight

public abstract class Piece
extends java.lang.Object
The abstract class that a game piece should extend.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private Player player
    The player that owns this piece.
  • Constructor Summary

    Constructors 
    Constructor Description
    Piece​(Player player)  
  • Method Summary

    Modifier and Type Method Description
    abstract Move[] getAvailableMoves​(Game game, Place source)
    Returns an array of moves that are valid given the current place of the piece.
    abstract char getLabel()
    Returns a char which is used to facilitate output in the console
    Player getPlayer()  

    Methods inherited from class java.lang.Object

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

    • player

      private final Player player
      The player that owns this piece.
  • Constructor Details

  • Method Details

    • getPlayer

      public final Player getPlayer()
    • getLabel

      public abstract char getLabel()
      Returns a char which is used to facilitate output in the console
      Returns:
      the label to represent the piece on the board
    • getAvailableMoves

      public abstract Move[] getAvailableMoves​(Game game, Place source)
      Returns an array of moves that are valid given the current place of the piece.
      Parameters:
      game - the game object
      source - the current place of the piece
      Returns:
      a set of available moves