Browse Source

Rover has now hard coded location and direction

Oz N Tiram 4 years ago
parent
commit
101d86cbb8
2 changed files with 23 additions and 2 deletions
  1. 15 1
      src/rover/rover.py
  2. 8 1
      tests/test_rover.py

+ 15 - 1
src/rover/rover.py

@@ -1,3 +1,17 @@
 
+DIRECTIONS = ['N', 'E', 'S', 'W']
+
+class Location:
+
+    def __init__(self, x, y, direction):
+        self.x = x
+        self.y = y
+        self.direction = direction
+
+
 class Rover:
-    pass
+
+    def __init__(self):
+        self.location = Location(2, 7, 'E')
+        self.location.x = 2
+        self.location.y = 7

+ 8 - 1
tests/test_rover.py

@@ -1,5 +1,12 @@
 from rover import Rover
-
+from rover.rover import DIRECTIONS
 
 def test_can_land():
     assert Rover()
+
+
+def test_has_location_and_direction():
+    rover = Rover()
+    assert isinstance(rover.location.x, int)
+    assert isinstance(rover.location.y, int)
+    assert rover.location.direction in DIRECTIONS