Class Archer

java.lang.Object
castle.comp3021.assignment.protocol.Piece
castle.comp3021.assignment.piece.Archer

public class Archer
extends Piece
Archer piece that moves similar to cannon in chinese chess. Rules of move of Archer can be found in wikipedia (https://en.wikipedia.org/wiki/Xiangqi#Cannon).

Attention: If you want to implement Archer as the bonus task, you should remove "throw new UnsupportedOperationException();" in the constructor of this class.

See Also:
Wikipedia
  • Constructor Summary

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

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

    Methods inherited from class castle.comp3021.assignment.protocol.Piece

    getPlayer

    Methods inherited from class java.lang.Object

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

  • Method Details

    • getLabel

      public char getLabel()
      Description copied from class: Piece
      Returns a char which is used to facilitate output in the console
      Specified by:
      getLabel in class Piece
      Returns:
      the label to represent the piece on the board
    • getAvailableMoves

      public Move[] getAvailableMoves​(Game game, Place source)
      Returns an array of moves that are valid given the current place of the piece. Given the Game object and the Place that current knight piece locates, this method should return ALL VALID Moves according to the current Place of this knight piece. All the returned Move should have source equal to the source parameter.

      Hint: you should consider corner cases when the Move is not valid on the gameboard. Several tests are provided and your implementation should pass them.

      Attention: Student should make sure all Moves returned are valid.

      Specified by:
      getAvailableMoves in class Piece
      Parameters:
      game - the game object
      source - the current place of the piece
      Returns:
      an array of available moves