Package castle.comp3021.assignment.piece
Class Knight
java.lang.Object
castle.comp3021.assignment.protocol.Piece
castle.comp3021.assignment.piece.Knight
public class Knight extends Piece
Knight piece that moves similar to knight in chess.
Rules of move of Knight can be found in wikipedia (https://en.wikipedia.org/wiki/Knight_(chess)).
- See Also:
- Wikipedia
-
Constructor Summary
-
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
-
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 -
getAvailableMoves
Returns an array of moves that are valid given the current place of the piece. Given theGame
object and thePlace
that current knight piece locates, this method should return ALL VALIDMove
s according to the currentPlace
of this knight piece. All the returnedMove
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
Move
s returned are valid.- Specified by:
getAvailableMoves
in classPiece
- Parameters:
game
- the game objectsource
- the current place of the piece- Returns:
- an array of available moves
-