Ajout generation grille, amélioration UI, commentaires
This commit is contained in:
47
Grid.java
47
Grid.java
@@ -7,9 +7,18 @@ public class Grid {
|
||||
|
||||
public Grid() {
|
||||
cells = new Cell[9][9];
|
||||
for (int ligne = 0; ligne < 9; ligne++) {
|
||||
for (int column = 0; column < 9; column++) {
|
||||
cells[ligne][column] = new Cell();
|
||||
for (int i = 0; i < 9; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
cells[i][j] = new Cell();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Grid(Grid grid) {
|
||||
cells = new Cell[9][9];
|
||||
for (int i = 0; i < 9; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
cells[i][j] = new Cell(grid.cells[i][j].getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,24 +44,24 @@ public class Grid {
|
||||
}
|
||||
}
|
||||
|
||||
public Cell getCell(int ligne, int column) {
|
||||
return cells[ligne][column];
|
||||
public Cell getCell(int ligne, int col) {
|
||||
return cells[ligne][col];
|
||||
}
|
||||
|
||||
public void setCell(int ligne, int column, int value) {
|
||||
cells[ligne][column].setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int ligne = 0; ligne < 9; ligne++) {
|
||||
for (int column = 0; column < 9; column++) {
|
||||
int value = cells[ligne][column].getValue();
|
||||
sb.append(value).append(" ");
|
||||
public void copyFrom(Grid other) {
|
||||
for (int row = 0; row < 9; row++) {
|
||||
for (int col = 0; col < 9; col++) {
|
||||
this.cells[row][col].setValue(other.cells[row][col].getValue());
|
||||
}
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public void printGrid() {
|
||||
for (int row = 0; row < 9; row++) {
|
||||
for (int col = 0; col < 9; col++) {
|
||||
System.out.print(cells[row][col].getValue() + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user