From a9810340300482c8b7799589c22bcc0bce8eafca Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Tue, 21 Jan 2025 20:58:24 +0100 Subject: [PATCH] setCell function --- app/src/main/java/sudoku/Sudoku.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/sudoku/Sudoku.java b/app/src/main/java/sudoku/Sudoku.java index e43350f..91a4bd6 100644 --- a/app/src/main/java/sudoku/Sudoku.java +++ b/app/src/main/java/sudoku/Sudoku.java @@ -21,6 +21,19 @@ public class Sudoku { this.constraints = constraints; } + /** + * Try to place a cell at the given coordinate + * @return false if it can't be done + */ + public boolean setCellSymbol(int x, int y, int value) { + for (IConstraint constraint : this.constraints) { + if (!constraint.canBePlaced(this, x, y, value)) { + return false; + } + } + return true; + } + public Cell getCell(int x, int y) { int index = y * getSize() + x; assert(index < getSize() * getSize());