Skip to content

Commit 94041c1

Browse files
fr2d9y2fr2d9y2
authored andcommitted
Refactor: move rover constructor to factory method in planet i prep for wrapping
1 parent 2226f26 commit 94041c1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

mars-rover/src/rover.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ class Rover:
33
global commands
44
global deltas
55

6-
def __init__(self, x, y, orientation):
6+
def __init__(self, x, y, orientation, planet):
77
self.x = x
88
self.y = y
99
self.orientation = orientation
10+
self.planet = planet
1011

1112
def move(self, commands):
1213
for command in commands:

mars-rover/test/test_rover.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from nose.tools import *
22
import rover
3+
import planet
34

45
def createRover(x, y, orientation):
5-
return rover.Rover(x, y, orientation)
6+
thePlanet = planet.Planet(100, 100)
7+
return thePlanet.createRover(x, y, orientation)
68

79
class TestRover:
810

0 commit comments

Comments
 (0)