rover: add direction field to Rover
This commit is contained in:
parent
b6d74b24eb
commit
0f1b861eee
|
@ -1,3 +1,4 @@
|
|||
import enum
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
|
@ -7,7 +8,15 @@ class Vector:
|
|||
y: int
|
||||
|
||||
|
||||
class Direction(enum.Enum):
|
||||
NORTH = "N"
|
||||
SOUTH = "S"
|
||||
EAST = "E"
|
||||
WEST = "W"
|
||||
|
||||
|
||||
@dataclass
|
||||
class Rover:
|
||||
pos: Vector = (0, 0)
|
||||
planet_size: Vector = (100, 100)
|
||||
dir: Direction = Direction.NORTH
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from rover import Rover
|
||||
from rover import Direction, Rover
|
||||
|
||||
|
||||
def test_rover_constructor():
|
||||
|
@ -9,3 +9,13 @@ def test_rover_constructor():
|
|||
def test_rover_default_values():
|
||||
rov = Rover()
|
||||
assert rov.pos == (0, 0) and rov.planet_size == (100, 100)
|
||||
|
||||
|
||||
def test_rover_has_direction():
|
||||
rov = Rover(dir=Direction.NORTH)
|
||||
assert rov.dir == Direction.NORTH
|
||||
|
||||
|
||||
def test_rover_default_direction_is_north():
|
||||
rov = Rover()
|
||||
assert rov.dir == Direction.NORTH
|
||||
|
|
Loading…
Reference in a new issue