20 lines
433 B
Java
20 lines
433 B
Java
package sudoku.constraint;
|
|
|
|
import sudoku.structure.Cell;
|
|
import sudoku.structure.Sudoku;
|
|
|
|
public class ColumnConstraint implements IConstraint {
|
|
|
|
@Override
|
|
public boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex) {
|
|
for (int i = 0; i < s.getSize(); i++) {
|
|
Cell cell = s.getCell(x, i);
|
|
int symbol = cell.getSymbolIndex();
|
|
if (symbol == newSymbolIndex) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|