begin multidoku display code
This commit is contained in:
@@ -7,6 +7,9 @@ public class Block {
|
||||
|
||||
private final List<Cell> cells;
|
||||
|
||||
// faster access to the sudoku
|
||||
private List<Sudoku> sudokus;
|
||||
|
||||
public Block(List<Cell> cells) {
|
||||
this.cells = cells;
|
||||
}
|
||||
@@ -39,4 +42,12 @@ public class Block {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Sudoku> getSudokus() {
|
||||
return sudokus;
|
||||
}
|
||||
|
||||
void setSudokus(List<Sudoku> sudokus) {
|
||||
this.sudokus = sudokus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,12 @@ public class Coordinate {
|
||||
return this.y * size + this.x;
|
||||
}
|
||||
|
||||
public Coordinate add(Coordinate other) {
|
||||
return new Coordinate(this.x + other.x, this.y + other.y);
|
||||
}
|
||||
|
||||
public Coordinate sub(Coordinate other) {
|
||||
return new Coordinate(this.x - other.x, this.y - other.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class Sudoku {
|
||||
private final List<Cell> cells;
|
||||
private final List<IConstraint> constraints;
|
||||
private boolean isMutable;
|
||||
private int blockWidth;
|
||||
|
||||
public Sudoku(List<Cell> cells, List<Block> blocks, List<IConstraint> constraints) {
|
||||
this.cells = cells;
|
||||
@@ -23,7 +24,7 @@ public class Sudoku {
|
||||
}
|
||||
|
||||
public int[] toCoords(int index) {
|
||||
return new int[]{index % getSize(), index / getSize()};
|
||||
return new int[] { index % getSize(), index / getSize() };
|
||||
}
|
||||
|
||||
public int toIndex(int x, int y) {
|
||||
@@ -71,6 +72,10 @@ public class Sudoku {
|
||||
}
|
||||
}
|
||||
|
||||
public int getBlockWidth() {
|
||||
return blockWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to place a cell at the given coordinate
|
||||
*
|
||||
@@ -162,6 +167,8 @@ public class Sudoku {
|
||||
throw new Exception("The given cell is not in this sudoku.");
|
||||
}
|
||||
|
||||
// TODO: use this.cells.indexOf();
|
||||
|
||||
for (Cell cell : this.cells) {
|
||||
if (cell == c) {
|
||||
return new Coordinate(x, y);
|
||||
|
||||
Reference in New Issue
Block a user