88 } |
87 } |
89 } |
88 } |
90 } |
89 } |
91 |
90 |
92 graphics.drawImage(img, 0, 0, this); |
91 graphics.drawImage(img, 0, 0, this); |
|
92 super.paintChildren(graphics); |
93 } |
93 } |
94 |
94 |
95 public int getCellValue(int x, int y) { |
95 public int getCellValue(int x, int y) { |
96 return cells[x][y].getValue(); |
96 return cells[x][y].getValue(); |
97 } |
97 } |
124 for (int y = 0 ; y < 9 ; y++) { |
124 for (int y = 0 ; y < 9 ; y++) { |
125 cells[x][y].setValue(0); |
125 cells[x][y].setValue(0); |
126 } |
126 } |
127 } |
127 } |
128 } |
128 } |
|
129 |
|
130 public int[][] getSquare(int x, int y) { |
|
131 if (x < 0 || x > 2 || y < 0 || y > 2) { |
|
132 throw new IllegalArgumentException("Invalid square coordinates"); |
|
133 } |
|
134 int[][] square = new int[3][3]; |
|
135 |
|
136 for (int u = 0 ; u < 3 ; u++) { |
|
137 for (int v = 0 ; v < 3 ; v++) { |
|
138 square[u][v] = getCellValue(3*x+u, 3*y+v); |
|
139 } |
|
140 } |
|
141 |
|
142 return square; |
|
143 } |
|
144 |
|
145 public int[] getRow(int y) { |
|
146 if (y < 0 || y > 8) { |
|
147 throw new IllegalArgumentException("Invalid row number"); |
|
148 } |
|
149 int row[] = new int[9]; |
|
150 |
|
151 for (int x = 0 ; x < 9 ; x++) { |
|
152 row[x] = getCellValue(x, y); |
|
153 } |
|
154 |
|
155 return row; |
|
156 } |
|
157 |
|
158 public int[] getColumn(int x) { |
|
159 if (x < 0 || x > 8) { |
|
160 throw new IllegalArgumentException("Invalid column number"); |
|
161 } |
|
162 int column[] = new int[9]; |
|
163 |
|
164 for (int y = 0 ; y < 9 ; y++) { |
|
165 column[y] = getCellValue(x, y); |
|
166 } |
|
167 |
|
168 return column; |
|
169 } |
129 } |
170 } |