King.java 609 Bytes
public class King extends Piece {

    public King(Cell cell, Color color) {
        super(cell, color) ;
    }

    @Override
    public boolean isValidMove(Cell c) {
        return ( (
                (this.getCell().getCol() == c.getCol() && Math.abs(this.getCell().getRow() - c.getRow()) == 1) ||
                        (this.getCell().getRow() == c.getRow() && Math.abs(this.getCell().getCol() - c.getCol()) == 1) ||
                        (Math.abs(this.getCell().getCol()-c.getCol())==1 && Math.abs(this.getCell().getRow()-c.getRow())==1)
        )
                && c.isEmpty()
        ) ;
    }
}