Beispiel #1
0
        private static bool isOnBoard(BoardSquare from, BoardSquare to)
        {
            if ((from.getRowCoord() >= 0 && from.getRowCoord() < Board.BOARD_ROW_COUNT) &&
                (from.getColumnCoord() >= 0 && from.getColumnCoord() < Board.BOARD_COLUMN_COUNT) &&
                (to.getRowCoord() >= 0 && to.getRowCoord() < Board.BOARD_ROW_COUNT) &&
                (to.getColumnCoord() >= 0 && to.getColumnCoord() < Board.BOARD_COLUMN_COUNT))
            {
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        private static bool isNeighbour(BoardSquare from, BoardSquare to)
        {
            if (((from.getRowCoord() + 1 == to.getRowCoord() && from.getColumnCoord() == to.getColumnCoord()) ||
                 (from.getRowCoord() - 1 == to.getRowCoord() && from.getColumnCoord() == to.getColumnCoord())) ^
                ((from.getColumnCoord() + 1 == to.getColumnCoord() && from.getRowCoord() == to.getRowCoord()) ||
                 (from.getColumnCoord() - 1 == to.getColumnCoord() && from.getRowCoord() == to.getRowCoord())))
            {
                return(true);
            }

            return(false);
        }