This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package sudoku;
|
package sudoku;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
public abstract class Cell {
|
public abstract class Cell {
|
||||||
|
|
||||||
protected static int NOSYMBOLE = -1;
|
protected static int NOSYMBOLE = -1;
|
||||||
@@ -32,11 +30,8 @@ public abstract class Cell {
|
|||||||
this.block = block;
|
this.block = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean equalsValue(Cell otherCell) {
|
||||||
public boolean equals(Object obj) {
|
return otherCell.getSymbolIndex() == this.getSymbolIndex();
|
||||||
if (obj instanceof Cell otherCell)
|
|
||||||
return otherCell.getSymbolIndex() == this.getSymbolIndex();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class Sudoku {
|
|||||||
public Sudoku(List<Cell> cells, List<Block> blocks, List<IConstraint> constraints) {
|
public Sudoku(List<Cell> cells, List<Block> blocks, List<IConstraint> constraints) {
|
||||||
this.cells = cells;
|
this.cells = cells;
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.constraints = new ArrayList<>(constraints);
|
this.constraints = constraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cell getCell(int x, int y) {
|
public Cell getCell(int x, int y) {
|
||||||
@@ -45,6 +45,14 @@ public class Sudoku {
|
|||||||
throw new Error("Function isValid() not implemented");
|
throw new Error("Function isValid() not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Cell> getCells() {
|
||||||
|
return this.cells;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Block> getBlocks() {
|
||||||
|
return this.blocks;
|
||||||
|
}
|
||||||
|
|
||||||
public List<MutableCell> getMutableCells() {
|
public List<MutableCell> getMutableCells() {
|
||||||
List<MutableCell> mutableCells = new ArrayList<>();
|
List<MutableCell> mutableCells = new ArrayList<>();
|
||||||
for (Cell cell : this.cells) {
|
for (Cell cell : this.cells) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class SudokuPrinter {
|
|||||||
}
|
}
|
||||||
String line = "[ ";
|
String line = "[ ";
|
||||||
for (int x = 0; x < s.getSize(); x++) {
|
for (int x = 0; x < s.getSize(); x++) {
|
||||||
line += (s.getCell(x, y).getSymboleIndex() + 1) + " ";
|
line += (s.getCell(x, y).getSymbolIndex() + 1) + " ";
|
||||||
if (x % blockWidth == blockWidth - 1 && x != blockWidth * blockHeight - 1) {
|
if (x % blockWidth == blockWidth - 1 && x != blockWidth * blockHeight - 1) {
|
||||||
line += "| ";
|
line += "| ";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class SudokuSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int blockID = blockIds.indexOf(block);
|
int blockID = blockIds.indexOf(block);
|
||||||
int symboleIndex = cell.getSymboleIndex();
|
int symboleIndex = cell.getSymbolIndex();
|
||||||
|
|
||||||
JSONObject cellJsonObject = new JSONObject();
|
JSONObject cellJsonObject = new JSONObject();
|
||||||
cellJsonObject.put("blockID", blockID);
|
cellJsonObject.put("blockID", blockID);
|
||||||
@@ -157,7 +157,7 @@ public class SudokuSerializer {
|
|||||||
sudokuBlocks.add(blocks.get(blockID));
|
sudokuBlocks.add(blocks.get(blockID));
|
||||||
}
|
}
|
||||||
|
|
||||||
sudokus.add(new Sudoku(sudokuCells, sudokuBlocks));
|
sudokus.add(new Sudoku(sudokuCells, sudokuBlocks, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MultiDoku(sudokus);
|
return new MultiDoku(sudokus);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package sudoku;
|
package sudoku;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|||||||
Reference in New Issue
Block a user