Exemplo n.º 1
0
        public bool HandleMovement()
        {
            //If can't handle the move operation then give the control to the ObstacleHandler.

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

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

            return(false);
        }
        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);
        }