|
@@ -1,3 +1,5 @@
|
|
|
|
+import random
|
|
|
|
+import warnings
|
|
|
|
|
|
DIRECTIONS = ['N', 'E', 'S', 'W']
|
|
DIRECTIONS = ['N', 'E', 'S', 'W']
|
|
|
|
|
|
@@ -12,6 +14,11 @@ class Location:
|
|
class Rover:
|
|
class Rover:
|
|
|
|
|
|
def __init__(self, x=None, y=None, direction=None):
|
|
def __init__(self, x=None, y=None, direction=None):
|
|
- self.location = Location(2, 7, 'E')
|
|
|
|
- self.location.x = 2
|
|
|
|
- self.location.y = 7
|
|
|
|
|
|
+ if all((x, y, direction)):
|
|
|
|
+ self.location = Location(x, y, direction)
|
|
|
|
+ else:
|
|
|
|
+ warnings.warn("Landing at a random place")
|
|
|
|
+ self.location = Location(random.randint(-10, 10),
|
|
|
|
+ random.randint(-10, 10),
|
|
|
|
+ DIRECTIONS[random.randint(0,
|
|
|
|
+ len(DIRECTIONS) - 1)])
|