private void setValue(Square square, int value) { if (square.hasValue()) { if (square.getValue() != value) { throw new IllegalArgumentException( "Illegal move!\n" + new Move(square.rowIdx, square.colIdx, value) + "\n" + this); } return; } if (square.row.contains(value) || square.col.contains(value) || square.group.contains(value)) { throw new IllegalArgumentException( "Illegal move!:\n" + new Move(square.rowIdx, square.colIdx, value) + "\n" + this); } square.setValue(value); eliminateCandidateValue(square.row, value); eliminateCandidateValue(square.col, value); eliminateCandidateValue(square.group, value); executeOnlyChoiceRule(); }
@Override public void visit(Square square) { if (!square.hasValue()) { remainingSquares++; } }