|
@@ -27,3 +27,18 @@ class Rover:
|
|
|
for item in command:
|
|
|
if item == 'F' and self.location.heading == 'E':
|
|
|
self.location.x += 1
|
|
|
+
|
|
|
+ if item == 'F' and self.location.heading == 'N':
|
|
|
+ self.location.y += 1
|
|
|
+ # ... TODO: add all directions and check constraints
|
|
|
+ # if going over the borders calculate roll-over ...
|
|
|
+ # e.g, if after a few moves X location is E is 11 it should be
|
|
|
+ # reported and saved as W -1.
|
|
|
+
|
|
|
+ # separate moving from reporting
|
|
|
+ self._report()
|
|
|
+
|
|
|
+ def _report(self):
|
|
|
+ """naive implementation that prints to stdout, can be changed to
|
|
|
+ send a radio message"""
|
|
|
+ print(f"Location ({self.location.x}, {self.location.y}) Heading {self.location.heading}")
|