Commit Graph

17 Commits (main)

Author SHA1 Message Date
Daniel Barlow 95d201eb2f deduplicate code in rotate method 2023-11-03 19:00:27 +00:00
Daniel Barlow 9a9bad4f71 reduce test prolixity with smarter use statement 2023-11-03 18:50:44 +00:00
Daniel Barlow 3af88ea712 remove casts to i32 2023-11-03 18:49:01 +00:00
Daniel Barlow 4f3fb62432 convert the other methods 2023-11-03 18:47:50 +00:00
Daniel Barlow 1cc78f1e54 convert forward into a method 2023-11-03 18:43:49 +00:00
Daniel Barlow d2f123bcf6 make Rover a struct instead of a raw tuple 2023-11-03 18:41:40 +00:00
Daniel Barlow 023923f06b improve names 2023-11-02 23:21:40 +00:00
Daniel Barlow e4bd2597d5 we can drive a rover with sequence of commands as string 2023-11-02 23:16:04 +00:00
Daniel Barlow f09e4d4bee use match instead of if/else
Rotation is an enum so leverage the compiler to tell us
we've considered all cases
2023-11-01 00:23:58 +00:00
Daniel Barlow c812b79363 implement rotation 2023-11-01 00:22:12 +00:00
Daniel Barlow a8e9ab810c implement backward()
this has meant changing the type signature of forward()
so that it accepts the rover by reference not value, and
making Facing a Copy type so that the direction passed to
forward can also be returned in its output
2023-10-31 23:51:45 +00:00
Daniel Barlow d8c0a21985 extract velocity function
note we have to pass a reference to "facing" not the
tuple itself, otherwise it owns it and we get
"value used here after move"
2023-10-31 23:32:20 +00:00
Daniel Barlow 2b65145621 add S W E 2023-10-31 23:27:07 +00:00
Daniel Barlow 5a148a2688 destructure rover in function param list 2023-10-31 23:17:36 +00:00
Daniel Barlow 9348808ea9 don't hardcode return value in forward() 2023-10-31 23:14:54 +00:00
Daniel Barlow 71d9c799b6 rover moves forward northward when pointing north 2023-10-31 22:51:32 +00:00
Daniel Barlow a4a80f450a "cargo new" and write a failing test 2023-10-31 22:10:48 +00:00