/* * King.java * * Created on February 10, 2007, 6:44 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package chess; /** * * @author Stanislav Hromek */ public class King extends Piece { private static final String name = "king"; private boolean moved; /** Creates a new instance of King */ public King(String pieceColor) { this.pieceColor = pieceColor; } /** * gives info, if king moved already, used for castling test */ boolean hasMoved() { return moved; } /** * sets moved parameter by first rook move to true */ void setHasMoved() { moved = true; } /** * for king road will be always ok, because there is none and we already checked start and end square * anyway, king is specific, as he cannot go to position with check */ boolean isRoadOk(Board board, String movePieceFrom, String movePieceTo) { return true; } boolean possibleToMoveToEndSquare(Board board, String movePieceFrom, String movePieceTo) { if(board.isNextSquare(movePieceFrom, movePieceTo)) return true; else return false; } public String getName() { return name; } }