class
SudokuGame {
private
lateint var grid: SudokuGrid
init {
createGame()
}
fun createGame() {
puzzle = SudokuGrid(
)
}
fun selectCell(col: Int, row:
int
) {
grid.selectCell(col, row)
}
}
data
class
CellsPos(val col: Int, val row:
int
)
data
class
SudokuCell(
val number: Int,
val isSelected: Boolean =
false
)
class
SudokuGrid(
private
val cells: HashMap<CellsPos, SudokuCell>
) {
fun selectCell(col:
int
, row:
int
) {
val selectedCell = cells[CellPos(col, row)] ?:
return
cells[CellPos(col, row)] = selectedCell.copy(isSelected =
true
)
}
}
private
val game = SudokuGame()
val gamboard: SudokuGameBoard = ...
gamboard.setOnClickListener { view: SudokuCellView, col: Int, row: Int ->
game.selectSell(col,row)
}