'How to enter Sudoku game notes in a 9x9 cell - Android studio
I'm newbie to java and Android studio. After many troubles and experience from a lots of mistakes, I have created sudoku game and it is almost finished but I have stuck at notes as shown in image (red box).
SudokuGame.java
public boolean[] notes = boolean[]{false, false, false, false, false, false, false, false, false};
public void setNotes(int notes) {
this.notes[notes - 1] = !this.notes[notes - 1];
}
SudokuView.java
public void drawNotes(Canvas canvas) {
int r = sudokuGame.selectedRow;
int c = sudokuGame.selectedColumn;
for (int row = 0; row < 9; row++) {
for (int col = 0; col < 9; col++) {
if (SudokuMain.notesStatustrue) {
if (sudokuGame.getBoard()[row][col] == sudokuGame.getBoard()[r][c]) {
cellNotesPaint(canvas, r, c, notesColor);
}
}
}
}
}
private void cellNotesPaint(Canvas canvas, int row, int col, int maskColor) {
notesPaint.setAntiAlias(true);
notesPaint.setColor(maskColor);
notesPaint.setTextSize(cellSize * 0.3f);
if (sudokuGame.notes[0]) {
canvas.drawText("1",
col * cellSize + cellSize * 0.2f,
row * cellSize + cellSize * 0.3f, notesPaint);
}
if (sudokuGame.notes[1]) {
canvas.drawText("2",
col * cellSize + cellSize * 0.5f,
row * cellSize + cellSize * 0.3f, notesPaint);
}
if (sudokuGame.notes[2]) {
canvas.drawText("3",
col * cellSize + cellSize * 0.8f,
row * cellSize + cellSize * 0.3f, notesPaint);
}
if (sudokuGame.notes[3]) {
canvas.drawText("4",
col * cellSize + cellSize * 0.2f,
row * cellSize + cellSize * 0.6f, notesPaint);
}
if (sudokuGame.notes[4]) {
canvas.drawText("5",
col * cellSize + cellSize * 0.5f,
row * cellSize + cellSize * 0.6f, notesPaint);
}
if (sudokuGame.notes[5]) {
canvas.drawText("6",
col * cellSize + cellSize * 0.8f,
row * cellSize + cellSize * 0.6f, notesPaint);
}
if (sudokuGame.notes[6]) {
canvas.drawText("7",
col * cellSize + cellSize * 0.2f,
row * cellSize + cellSize * 0.9f, notesPaint);
}
if (sudokuGame.notes[7]) {
canvas.drawText("8",
col * cellSize + cellSize * 0.5f,
row * cellSize + cellSize * 0.9f, notesPaint);
}
if (sudokuGame.notes[8]) {
canvas.drawText("9",
col * cellSize + cellSize * 0.8f,
row * cellSize + cellSize * 0.9f, notesPaint);
}
}
SudokuMain.java
if (notesStatus) { sudokuGame.setNotes(inputNumber); }
My problem is, when I clicked 1 to 9 buttons the same notes are showing in all selected cells (even in locked cells also). I want to show the notes in individual entered cells of different numbers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

