R: Move move() into Heading.move(Position)

This commit is contained in:
Paul Hameteman 2025-10-14 22:52:06 +02:00
commit 84e78f18d3
3 changed files with 31 additions and 29 deletions

View file

@ -21,12 +21,9 @@ class Rover {
}
private fun move() {
when (state.heading) {
Heading.EAST -> state.positionX++
Heading.SOUTH -> state.positionY--
Heading.WEST -> state.positionX--
Heading.NORTH -> state.positionY++
}
val (updatedX, updatedY) = state.heading.move(state.positionX, state.positionY)
state.positionX = updatedX
state.positionY = updatedY
}
private fun turnRight() {