Example #1
0
    def test_example2(self):
        robot = Robot()

        robot.place(0, 0, "NORTH")
        self.assertEqual(robot.report(), "(0, 0, NORTH)")

        robot.left()
        self.assertEqual(robot.report(), "(0, 0, WEST)")

        robot.report()
        self.assertEqual(robot.report(), "(0, 0, WEST)")
Example #2
0
    def test_example3(self):
        robot = Robot()

        robot.place(1, 2, "EAST")
        self.assertEqual(robot.report(), "(1, 2, EAST)")

        robot.move()
        self.assertEqual(robot.report(), "(2, 2, EAST)")

        robot.move()
        self.assertEqual(robot.report(), "(3, 2, EAST)")

        robot.left()
        self.assertEqual(robot.report(), "(3, 2, NORTH)")

        robot.move()
        self.assertEqual(robot.report(), "(3, 3, NORTH)")

        robot.report()
        self.assertEqual(robot.report(), "(3, 3, NORTH)")


# Code by Niroo Arjuna
Example #3
0
    def test_lefttest(self):
        robot = Robot()

        robot.place(4, 4, "EAST")

        # turn around full circle
        robot.left()
        self.assertEqual(robot.report(), "(4, 4, NORTH)")

        robot.left()
        self.assertEqual(robot.report(), "(4, 4, WEST)")

        robot.left()
        self.assertEqual(robot.report(), "(4, 4, SOUTH)")

        robot.left()
        self.assertEqual(robot.report(), "(4, 4, EAST)")
Example #4
0
            try:
                xCoordinate = int(words[1])
                yCoordinate = int(words[2])
                direction = words[3]

                robot.place(xCoordinate, yCoordinate, direction)
            except ValueError:
                print(
                    "Error: Invalid command parameters, please enter valid command parameters"
                )
        else:
            print("Error: Invalid syntax, please enter valid syntax")
    elif words[0] == "MOVE":
        robot.move()
    elif words[0] == "LEFT":
        robot.left()
    elif words[0] == "RIGHT":
        robot.right()
    elif words[0] == "REPORT":
        robot.report()
    elif words[0] == "AVOID":
        if len(words) == 3:
            try:
                xCoordinate = int(words[1])
                yCoordinate = int(words[2])
                robot.avoid(xCoordinate, yCoordinate)
            except ValueError:
                print(
                    "Error: Invalid command parameters, please enter valid command parameters"
                )
        else: