def test_rotate_right_command_move(self): rotate_right_command = RotateRightCommand() position = Position(1, 1, Commands.NORTH) new_position = rotate_right_command.move(position) self.assertEqual(new_position.direction, Commands.EAST)
def test_north_command_move(self): north_command = NorthCommand() position = Position(1, 1, Commands.NORTH) new_position = north_command.move(position) self.assertEqual(new_position.y, 2)
def move(self, position): left_rotations = { Directions.NORTH: Directions.WEST, Directions.WEST: Directions.SOUTH, Directions.SOUTH: Directions.EAST, Directions.EAST: Directions.NORTH, } return Position(position.x, position.y, left_rotations[position.direction])
def move(self, position): return Position(position.x - 1, position.y, position.direction)