R: Rover.constructor use copy() on state
This commit is contained in:
parent
b1d82fe8fd
commit
eb63607e53
2 changed files with 8 additions and 5 deletions
|
|
@ -11,8 +11,8 @@
|
||||||
- [ ] Rover.turnLeft use copy() on state
|
- [ ] Rover.turnLeft use copy() on state
|
||||||
- [ ] Rover.turnRight use copy() on state
|
- [ ] Rover.turnRight use copy() on state
|
||||||
- [ ] Rover.move use copy() on state
|
- [ ] Rover.move use copy() on state
|
||||||
- [ ] Rover.constructor use copy() on state
|
- [x] Rover.constructor use copy() on state
|
||||||
- [ ] Change RoverState to Data Class
|
- [x] Change RoverState to Data Class
|
||||||
|
|
||||||
# RPP
|
# RPP
|
||||||
- [ ] Refine Abstractions
|
- [ ] Refine Abstractions
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,12 @@ class Rover {
|
||||||
constructor(commands: String) {
|
constructor(commands: String) {
|
||||||
val command = commands.split(' ')
|
val command = commands.split(' ')
|
||||||
if (command.size >= ROVER_MINIMUM_NEEDED_COMMANDS) {
|
if (command.size >= ROVER_MINIMUM_NEEDED_COMMANDS) {
|
||||||
state.positionX = command[ROVER_STARTING_POSITION_X].toInt()
|
state =
|
||||||
state.positionY = command[ROVER_STARTING_POSITION_Y].toInt()
|
state.copy(
|
||||||
state.heading = Heading.from(command[ROVER_FACING_DIRECTION][ROVER_COMMANDLIST_DIRECTION]) ?: Heading.NORTH
|
positionX = command[ROVER_STARTING_POSITION_X].toInt(),
|
||||||
|
positionY = command[ROVER_STARTING_POSITION_Y].toInt(),
|
||||||
|
heading = Heading.from(command[ROVER_FACING_DIRECTION][ROVER_COMMANDLIST_DIRECTION]) ?: state.heading,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue