public Rover(int x, int y, Direction direction, ILandingSurface landingSurface) { X = x; Y = y; Direction = direction; LandingSurface = landingSurface; }
public Rover(ILandingSurface landingSurface, INavigationAdvisor navigationAdvisor, IReport report, IValidator validator) { _landingSurface = landingSurface; _navigationAdvisor = navigationAdvisor; _report = report; _validator = validator; }
public Orientation Navigate(ILandingSurface landingSurface, CardinalDirection currentCardinalDirection, Position currentPosition, Movement movement) { Orientation orientation = new Orientation { Position = new Position { X = currentPosition.X, Y = currentPosition.Y }, CardinalDirection = currentCardinalDirection }; IDictionary <Movement, Action> movementMethodDictionary = new Dictionary <Movement, Action>(); IDictionary <CardinalDirection, Action> leftMoveDictionary = new Dictionary <CardinalDirection, Action>(); IDictionary <CardinalDirection, Action> rightMoveDictionary = new Dictionary <CardinalDirection, Action>(); IDictionary <CardinalDirection, Action> forwardMoveDictionary = new Dictionary <CardinalDirection, Action>(); movementMethodDictionary = new Dictionary <Movement, Action> { { Movement.SpinLeft, () => leftMoveDictionary[currentCardinalDirection].Invoke() }, { Movement.SpinRight, () => rightMoveDictionary[currentCardinalDirection].Invoke() }, { Movement.StepForward, () => forwardMoveDictionary[currentCardinalDirection].Invoke() } }; leftMoveDictionary = new Dictionary <CardinalDirection, Action> { { CardinalDirection.North, () => orientation.CardinalDirection = CardinalDirection.West }, { CardinalDirection.East, () => orientation.CardinalDirection = CardinalDirection.North }, { CardinalDirection.South, () => orientation.CardinalDirection = CardinalDirection.East }, { CardinalDirection.West, () => orientation.CardinalDirection = CardinalDirection.South } }; rightMoveDictionary = new Dictionary <CardinalDirection, Action> { { CardinalDirection.North, () => orientation.CardinalDirection = CardinalDirection.East }, { CardinalDirection.East, () => orientation.CardinalDirection = CardinalDirection.South }, { CardinalDirection.South, () => orientation.CardinalDirection = CardinalDirection.West }, { CardinalDirection.West, () => orientation.CardinalDirection = CardinalDirection.North } }; forwardMoveDictionary = new Dictionary <CardinalDirection, Action> { { CardinalDirection.North, () => { orientation.Position = new Position(currentPosition.X, currentPosition.Y + STEPINCREMENT); } }, { CardinalDirection.East, () => { orientation.Position = new Position(currentPosition.X + STEPINCREMENT, currentPosition.Y); } }, { CardinalDirection.South, () => { orientation.Position = new Position(currentPosition.X, currentPosition.Y - STEPINCREMENT); } }, { CardinalDirection.West, () => { orientation.Position = new Position(currentPosition.X - STEPINCREMENT, currentPosition.Y); } } }; movementMethodDictionary[movement].Invoke(); if (!landingSurface.IsValid(orientation.Position)) { var exceptionMessage = string.Format("Rover has moved out of bounds ({0},{1}). Landing surface size is {2}.", orientation.Position.X, orientation.Position.Y, landingSurface.GetSize().GetFormattedDescription()); throw new NavigatedOutOfBoundsException(exceptionMessage); } return(orientation); }
private static void throwDeployException(ILandingSurface aLandingSurface, Point aPoint) { var size = aLandingSurface.GetSize(); var exceptionMessage = String.Format("Deploy failed for point ({0},{1}). Landing surface size is {2} x {3}.", aPoint.X, aPoint.Y, size.Width, size.Height); throw new RoverDeployException(exceptionMessage); }
public Rover(ILandingSurface landingSurface, string roverPosition, string roverCommands) { this.TranslateRoverPosition(roverPosition); if (RoverIsBetweenLandingCoordinates(landingSurface)) { this.TranslateRoverCommands(roverCommands); } }
public void RoverIsWithinLandingCoordinate(ILandingSurface landingSurface) { if ((this.XCoordinate < 0) || (this.XCoordinate > landingSurface.Width) || (this.YCoordinate < 0) || (this.YCoordinate > landingSurface.Height)) { this.DirectionFacing = Facing.OUTOFBound; this.XCoordinate = 0; this.YCoordinate = 0; } }
public CommandCenter(ILandingSurface aLandingSurface, ICommandParser aCommandParser, ICommandInvoker aCommandInvoker, IReportComposer aReportComposer) { rovers = new List <IRover>(); landingSurface = aLandingSurface; commandParser = aCommandParser; commandInvoker = aCommandInvoker; reportComposer = aReportComposer; commandInvoker.SetLandingSurface(landingSurface); commandInvoker.SetRovers(rovers); }
public CommandCenter(ILandingSurface aLandingSurface, ICommandParser aCommandParser, ICommandInvoker aCommandInvoker, IReportComposer aReportComposer) { rovers = new List<IRover>(); landingSurface = aLandingSurface; commandParser = aCommandParser; commandInvoker = aCommandInvoker; reportComposer = aReportComposer; commandInvoker.SetLandingSurface(landingSurface); commandInvoker.SetRovers(rovers); }
public void Move(IEnumerable <Movement> movements, ILandingSurface landingSurface) { foreach (var move in movements) { var orientation = _navigator.Navigate(landingSurface, CardinalDirection, Position, move); Position = orientation.Position; CardinalDirection = orientation.CardinalDirection; } }
public void Deploy(ILandingSurface aLandingSurface, Point aPoint, CardinalDirection aDirection) { if (aLandingSurface.IsValid(aPoint)) { Position = aPoint; CardinalDirection = aDirection; isDeployed = true; return; } throwDeployException(aLandingSurface, aPoint); }
public Rover(ILandingSurface landingSurface, string roverPosition, string roverCommands) { _LandingSurface = landingSurface; SetRoverPosition(roverPosition); if (!RoverIsWithinLandingCoordinates()) { return; } _RoverCommands = roverCommands; }
public Rover(ILandingSurface landingSurface, string roverPosition, string roverCommands) { TranslateRoverPosition(roverPosition); if (!IsWithinLandingSurface(landingSurface)) { throw new InvalidOperationException(); } else { TranslateRoverCommands(roverCommands); } }
public Mission(ILandingSurface landingSurface, ICommandParser commandParser, ICommandInvoker commandInvoker, IReportBuilder reportBuilder) { _rovers = new List <IRover>(); _commandParser = commandParser; _commandInvoker = commandInvoker; _commandInvoker.SetLandingSurface(landingSurface); _commandInvoker.SetRovers(_rovers); _reportBuilder = reportBuilder; }
public void Deploy(ILandingSurface landingSurface, Position position, CardinalDirection cardinalDirection) { if (!landingSurface.IsValid(position)) { var exceptionMessage = string.Format("Deploy failed for point ({0},{1}). Landing surface size is {2}.", position.X, position.Y, landingSurface.GetSize().GetFormattedDescription()); throw new RoverDeployException(exceptionMessage); } Position = position; CardinalDirection = cardinalDirection; _isDeployed = true; }
public Rover(List <IRover> squad, ILandingSurface landingSurface, string roverPosition, string roverCommands) { this.Squad = squad; this.TranslateRoverPosition(roverPosition); if (!RoverIsWithinLandingCoordinates(landingSurface)) { return; } this.TranslateRoverCommands(roverCommands); }
public Rover(List <IRover> squad, ILandingSurface landingSurface, string roverPosition, string roverCommands) { this.Squad = squad; this.TranslateRoverPosition(roverPosition); this.TranslateRoverCommands(roverCommands); this.RoverIsWithinLandingCoordinate(landingSurface); this.Height = landingSurface.Height; this.Width = landingSurface.Width; }
public Houston(ILandingSurface landingSurface, CommandManager commandManager) { _landingSurface = landingSurface; _commandManager = commandManager; }
public void SetLandingSurface(ILandingSurface aLandingSurface) { landingSurface = aLandingSurface; }
public void SetReceivers(IRover aRover, ILandingSurface aLandingSurface) { rover = aRover; landingSurface = aLandingSurface; }
private bool RoverIsBetweenLandingCoordinates(ILandingSurface landingSurface) { return((this.XCoordinate >= 0) && (this.XCoordinate < landingSurface.Width) && (this.YCoordinate >= 0) && (this.YCoordinate < landingSurface.Height)); }
public void SetReceivers(IRover aRover, ILandingSurface aLandingSurface) { rover = aRover; landingSurface = aLandingSurface; }
public void SetLandingSurface(ILandingSurface aLandingSurface) { landingSurface = aLandingSurface; }
public RoverSquad(ILandingSurface landingSurface) { this.LandingSurface = landingSurface; }
public void SetReceiver(ILandingSurface aLandingSurface) { landingSurface = aLandingSurface; }
public PlataueCommandExecuter(IServiceProvider serviceProvider) { _landingSurface = serviceProvider.GetService <ILandingSurface>(); }
public RoverSquadManager(ILandingSurface landingSurface) { LandingSurface = landingSurface; }
private bool IsWithinLandingSurface(ILandingSurface landingSurface) { return((XCoordinate >= 0) && (XCoordinate < landingSurface.XCoordinate) && (YCoordinate >= 0) && (YCoordinate < landingSurface.YCoordinate)); }
public void SetReceiver(ILandingSurface aLandingSurface) { landingSurface = aLandingSurface; }
public void InitializeTest() { _StaticCoordinatesSurface = new Surface(8, 8); }