Exemple #1
0
 public void Change(IReturnAlgorithm returnAlgorithm, IRobotCleaner robot)
 {
     returnAlgorithm.Step = new FourthStep();
     robot.TurnLeft();
     robot.TurnLeft();
     robot.Advance();
 }
Exemple #2
0
        public void Change(IReturnAlgorithm returnAlgorithm, IRobotCleaner robot)
        {
            var position = new FinalState(robot.X, robot.Y, robot.FaceTo);
            var response = new ResponseDto(robot.Map.Visited, robot.Map.Cleaned, position, robot.Battery);

            throw new OutOfMovesException("Robot ran out of moves", JsonConvert.SerializeObject(response));
        }
Exemple #3
0
 public void Change(IReturnAlgorithm returnAlgorithm, IRobotCleaner robot)
 {
     returnAlgorithm.Step = new FifthStep();
     robot.TurnRight();
     robot.Back();
     robot.TurnRight();
     robot.Advance();
 }
        /// <summary>
        /// Calls the respective command based on the parameter given in the constructor.
        /// When it's done, an final status will be returned as result of the operation.
        /// </summary>
        /// <param name="robot"></param>
        /// <returns></returns>
        public ResponseDto Clean(IRobotCleaner robot)
        {
            foreach (var command in _commands)
            {
                _com[command].Execute(robot);
            }

            var position = new FinalState(robot.X, robot.Y, robot.FaceTo);
            var response = new ResponseDto(robot.Map.Visited, robot.Map.Cleaned, position, robot.Battery);

            return(response);
        }
Exemple #5
0
        public void MoveBackwards(IRobotCleaner robot)
        {
            var nextCell = robot.Y + 1;

            if (!robot.IsObstacle(robot.X, nextCell))
            {
                robot.Y += 1;
            }
            else
            {
                robot.Return();
            }
        }
Exemple #6
0
        public void MoveForward(IRobotCleaner robot)
        {
            var nextCell = robot.Y - 1;

            if (!robot.IsObstacle(robot.X, nextCell))
            {
                robot.Y -= 1;
            }
            else
            {
                robot.Return();
            }
        }
        public void MoveForward(IRobotCleaner robot)
        {
            var nextCell = robot.X + 1;

            if (!robot.IsObstacle(nextCell, robot.Y))
            {
                robot.X += 1;
            }
            else
            {
                robot.Return();
            }
        }
Exemple #8
0
 public void Execute(IRobotCleaner robotCleaner)
 {
     robotCleaner.Advance();
 }
Exemple #9
0
 public void Execute(IRobotCleaner robotCleaner)
 {
     robotCleaner.Back();
 }
Exemple #10
0
 public void Execute(IRobotCleaner robotCleaner)
 {
     robotCleaner.CleanCell();
 }
Exemple #11
0
 public void Return(IRobotCleaner robot)
 {
     Step.Change(this, robot);
 }
Exemple #12
0
 public void Execute(IRobotCleaner robotCleaner)
 {
     robotCleaner.TurnRight();
 }
Exemple #13
0
 private Orchestrator(ConsoleParser consoleParser, IRobotCleaner robotCleaner)
 {
     _consoleParser = consoleParser;
     _robotCleaner  = robotCleaner;
 }
 protected static void Setup()
 {
     StartLocation = new Domain.Location(XCoordinate, YCoordinate);
     RobotCleaner  = new RobotCleaner(StartLocation, Commands);
 }