fix block contraint
Some checks failed
Linux arm64 / Build (push) Failing after 19s

This commit is contained in:
2025-01-21 19:16:18 +01:00
parent 4bd55d4ce4
commit 4e33318ba0
2 changed files with 10 additions and 10 deletions

View File

@@ -23,4 +23,12 @@ public class Block {
this.cells.add(newCell);
}
public boolean containsSymbol(int symbolIndex) {
for (Cell cell : getCells()) {
if (cell.getSymbolIndex() == symbolIndex)
return true;
}
return false;
}
}

View File

@@ -1,22 +1,14 @@
package sudoku.constraint;
import sudoku.Block;
import sudoku.MutableCell;
import sudoku.Sudoku;
public class BlockConstraint implements IConstraint{
@Override
public boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex) {
/*
boolean result = true;
for (Block block : s.getCell(x, y).getBlockContainers()) {
result = result && (!block.getCells().contains(new MutableCell(newSymbolIndex)));
}
*/
return !s.getBlocks().getCells().contains(new MutableCell(newSymbolIndex));
Block bloc = s.getCell(x, y).getBlock();
return !bloc.containsSymbol(newSymbolIndex);
}
}