R: ktlint

This commit is contained in:
Paul Hameteman 2025-10-14 23:11:40 +02:00
commit c5ce275612
2 changed files with 7 additions and 5 deletions

View file

@ -8,8 +8,8 @@
# Mikado # Mikado
- [ ] Change var to val (immutable) - [ ] Change var to val (immutable)
- [ ] Rover.turnLeft use copy() on state - [x] Rover.turnLeft use copy() on state
- [ ] Rover.turnRight use copy() on state - [x] Rover.turnRight use copy() on state
- [x] Rover.move use copy() on state - [x] Rover.move use copy() on state
- [x] Rover.constructor use copy() on state - [x] Rover.constructor use copy() on state
- [x] Change RoverState to Data Class - [x] Change RoverState to Data Class

View file

@ -8,7 +8,9 @@ class Rover {
state.copy( state.copy(
positionX = command[ROVER_STARTING_POSITION_X].toInt(), positionX = command[ROVER_STARTING_POSITION_X].toInt(),
positionY = command[ROVER_STARTING_POSITION_Y].toInt(), positionY = command[ROVER_STARTING_POSITION_Y].toInt(),
heading = Heading.from(command[ROVER_FACING_DIRECTION][ROVER_COMMANDLIST_DIRECTION]) ?: state.heading, heading =
Heading.from(command[ROVER_FACING_DIRECTION][ROVER_COMMANDLIST_DIRECTION])
?: state.heading,
) )
} }
} }
@ -29,11 +31,11 @@ class Rover {
} }
private fun turnRight() { private fun turnRight() {
state.heading = state.heading.turnRight() state = state.copy(heading = state.heading.turnRight())
} }
private fun turnLeft() { private fun turnLeft() {
state.heading = state.heading.turnLeft() state = state.copy(heading = state.heading.turnLeft())
} }
val position: String val position: String