This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user