예제 #1
0
    def test_righttest(self):
        robot = ToyRobot()

        robot.place(0, 3, "EAST")

        # turn around full circle
        robot.right()
        self.assertEqual(robot.report(), "(0, 3, SOUTH)")

        robot.right()
        self.assertEqual(robot.report(), "(0, 3, WEST)")

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

        robot.right()
        self.assertEqual(robot.report(), "(0, 3, EAST)")
예제 #2
0
파일: start.py 프로젝트: tmatkovic/ToyRobot
    text_upper = text_entered.upper()
    # split user input to a list
    words = text_upper.split()

    # first word should contain command
    if words[0] == "PLACE":
        # command + three parameters - PLACE X Y FACING
        if len(words) == 4:
            try:
                xCoord = int(words[1])
                yCoord = int(words[2])
                facing = words[3]

                robot.place(xCoord, yCoord, facing)
            except ValueError:
                print("Invalid command parameters")
        else:
            print("Invalid 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] == "QUIT":
        condition = False
    else:
        print("Unknown command...")