@Override
    public int numberOfLivingNeighbors(int x, int y) {
        int numberOfLivingNeighbors = 0;
        int xPositive = ensurePositiveCoordinate(x, getBoardWidth());
        int yPositive = ensurePositiveCoordinate(y, getBoardHeight());

        for (int i = -1; i < 2; i++) {
            for (int j = -1; j < 2; j++) {
                if (!(i == 0 && j == 0)) {
                    int xCoordinate = (xPositive + i) % getBoardWidth();
                    int yCoordinate = (yPositive + j) % getBoardHeight();
                    if (board[xCoordinate][yCoordinate].isAlive()) {
                        numberOfLivingNeighbors++;
                    }
                }
            }
        }

        return numberOfLivingNeighbors;
    }