mercredi 3 octobre 2018

Why eclipse is saying that my method doesn't return a valid result?

I've been doing this code in java for a Sudoku game since a while and I don't know what's wrong, Maybe is the "if" or de "For", but the IDE says that my method doesn't return a booelean type.

// check if the number has already been used in the columns
private boolean checkColumns(int x, int y, int value) {
    for (int j = 0; j < 9; j++) {
        if (this.gridPlayer[j][y].getValue() == value) return false;
        else return true;
    }

    }
// Check if the number has already been used in the lines
private boolean checkLines(int x, int y, int value) {
    for (int i = 0; i <= 9; i++) {
        if (this.gridPlayer[x][i].getValue() == value) return false;
         else return true;
    }
    }

// Check if the number has already been used and the subGrid
private boolean checkSubGrid(int x, int y) {
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            if (this.gridPlayer[x][y].getValueOfSubGrid(x, y) == this.gridPlayer[i][j].getValueOfSubGrid(i, j)) {
                if (this.gridPlayer[x][y].getValue() == this.gridPlayer[i][j].getValue()) {
                    return false;
                } else {
                    return true;
                }
            } else if (this.gridPlayer[x][y].getValueOfSubGrid(x, y) != this.gridPlayer[i][j].getValueOfSubGrid(i,
                    j)) {
                return true;
            }
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire