Exemplo n.º 1
0
        public static void TurnToFaceUp(AlgorithmEssentials inAlgorithmEssentials)
        {
            // Turn to the top side.
            switch (inAlgorithmEssentials.Robot.FaceTo)
            {
            case 0:
                RobotUtility.TurnLeft(inAlgorithmEssentials);
                break;

            case 1:
                RobotUtility.TurnRight(inAlgorithmEssentials);
                RobotUtility.TurnRight(inAlgorithmEssentials);
                break;

            case 2:
                RobotUtility.TurnRight(inAlgorithmEssentials);
                break;
            }
        }
        public bool HandleMovement()
        {
            // Handle the obstacle by turning right. If 3 right turns can't find a way,
            // then the Robot completed cleaning the room.

            RobotUtility.TurnRight(_algorithmEssentials);

            if (RobotUtility.CanRobotMoveForward(_algorithmEssentials, _canReUseVisitedCells))
            {
                return(true);
            }

            if ((null != _nextHandler))
            {
                return(_nextHandler.HandleMovement());
            }

            return(false);
        }