fillCell method
Fill a particular Cell at position
with value
, and returns a list of
CellViolation
For what violations are, please refer to CellViolation
enum
Implementation
List<CellViolation> fillCell(Position position, int value) {
Cell _target = _board!.cellAt(position);
_target.setValue(value);
List<CellViolation> _violations = new List<CellViolation>.empty(growable: true);
if (board()!.isRowViolated(position)) {
_violations.add(CellViolation.Row);
}
if (board()!.isColumnViolated(position)) {
_violations.add(CellViolation.Column);
}
if (board()!.isSegmentViolated(position)) {
_violations.add(CellViolation.Segment);
}
if (_target.getValue() !=
_solver.solvedBoard()!.cellAt(position).getValue()) {
_violations.add(CellViolation.Solution);
}
return _violations;
}