This commit is contained in:
@@ -23,4 +23,12 @@ public class Block {
|
|||||||
this.cells.add(newCell);
|
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;
|
package sudoku.constraint;
|
||||||
|
|
||||||
import sudoku.Block;
|
import sudoku.Block;
|
||||||
import sudoku.MutableCell;
|
|
||||||
import sudoku.Sudoku;
|
import sudoku.Sudoku;
|
||||||
|
|
||||||
public class BlockConstraint implements IConstraint{
|
public class BlockConstraint implements IConstraint{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex) {
|
public boolean canBePlaced(final Sudoku s, int x, int y, int newSymbolIndex) {
|
||||||
|
Block bloc = s.getCell(x, y).getBlock();
|
||||||
/*
|
return !bloc.containsSymbol(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));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user