R: Move move() into Heading.move(Position)
This commit is contained in:
parent
4e3d9177af
commit
84e78f18d3
3 changed files with 31 additions and 29 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue