Skip to content

Commit

Permalink
refactor(board): use the kotlin style loops
Browse files Browse the repository at this point in the history
  • Loading branch information
Pablito2020 committed Apr 16, 2022
1 parent 480f1fb commit d3912f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/kotlin/board/Board.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Board(private val row: Int, private val column: Int) {
}

private fun initializeBoard(row: Int, column: Int) {
for (rows in 0..row - 1) {
for (rows in 0 until row) {
val currentList: ArrayList<Cell> = ArrayList()
for (columns in 0..column - 1)
for (columns in 0 until column)
currentList.add(Cell.EMPTY)
board.add(currentList)
}
Expand All @@ -29,11 +29,11 @@ class Board(private val row: Int, private val column: Int) {
fun isEmpty(position: Position): Boolean {
if (!isInside(position))
throw InvalidPositionException()
return board.get(position.row).get(position.column) == Cell.EMPTY
return board[position.row][position.column] == Cell.EMPTY
}

fun writePosition(cell: Cell, position: Position) {
board.get(position.row).set(position.column, cell)
board[position.row][position.column] = cell
}

}

0 comments on commit d3912f1

Please sign in to comment.