1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
public class Grille {
//public int[][] board = new int[9][9];
int Line;
int Row;
int Value;
public int[][] board =
{{0,0,4,8,0,6,9,1,7},
{0,0,0,1,4,9,2,0,5},
{1,0,9,5,0,7,4,0,8},
{4,3,6,7,9,0,0,2,1},
{0,0,2,4,6,1,0,9,3},
{9,1,0,2,0,3,0,4,6},
{2,8,1,6,7,4,3,5,9},
{7,9,5,3,1,2,6,8,4},
{6,4,3,9,0,0,1,7,2}};
public int getLine() {
return Line;
}
public int getRow() {
return Row;
}
public int getValue() {
return Value;
}
public void setPlacement(int x, int y, int z) {
this.Line = x;
this.Row = y;
this.Value = z;
board[x][y]=z;
System.out.println(board[x][y]);
System.out.println("ligne; " + x + " colonne; " + y + " Valeur; " + z);
}
public void printGrille() {
for (int i = 0; i < 9; i++) {
System.out.print("\n");
if(i%3==0)
System.out.print("\n");
for (int j = 0; j < 9; j++) {
if (j % 3 == 0)
System.out.print(" ");
if (board[i][j] == 0)
System.out.print(". ");
if (board[i][j] == 1)
System.out.print("1 ");
if (board[i][j] == 2)
System.out.print("2 ");
if (board[i][j] == 3)
System.out.print("3 ");
if (board[i][j] == 4)
System.out.print("4 ");
if (board[i][j] == 5)
System.out.print("5 ");
if (board[i][j] == 6)
System.out.print("6 ");
if (board[i][j] == 7)
System.out.print("7 ");
if (board[i][j] == 8)
System.out.print("8 ");
if (board[i][j] == 9)
System.out.print("9 ");
}
}
System.out.print("\n\n");
}
} |
Partager