public void Change(IReturnAlgorithm returnAlgorithm, IRobotCleaner robot) { returnAlgorithm.Step = new FourthStep(); robot.TurnLeft(); robot.TurnLeft(); robot.Advance(); }
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)); }
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); }
public void MoveBackwards(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.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(); } }
public void Execute(IRobotCleaner robotCleaner) { robotCleaner.Advance(); }
public void Execute(IRobotCleaner robotCleaner) { robotCleaner.Back(); }
public void Execute(IRobotCleaner robotCleaner) { robotCleaner.CleanCell(); }
public void Return(IRobotCleaner robot) { Step.Change(this, robot); }
public void Execute(IRobotCleaner robotCleaner) { robotCleaner.TurnRight(); }
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); }