示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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])
示例#4
0
 def move(self, position):
     return Position(position.x - 1, position.y, position.direction)