public void GivenTheRoverIsLocatedAt(string p0) { _planetSurface = new PlanetSurface(100); _roverInvoker = new RoverInvoker(); _roverClient = new RoverClient(_roverInvoker, _planetSurface); StringAssert.Contains(p0, _roverClient.RoversCurrentLocation()); }
public MarsRover(string initialPos, string moveCommands, IPlanetSurface planet) { initialPos = initialPos.ToUpper(); //Convert all commands to uppercase string[] positionXY = initialPos.Split(' ', (char)StringSplitOptions.RemoveEmptyEntries); if (positionXY.Length != 3) { throw new MRSquadException("Rover position must consist of two coordinates (X and Y)"); } int parsedX; if (!Int32.TryParse(positionXY[0].ToString(), out parsedX)) { throw new MRSquadException("Rover X position must be an integer"); } _x = parsedX; int parsedY; if (!Int32.TryParse(positionXY[1].ToString(), out parsedY)) { throw new MRSquadException("Rover Y position must be an integer"); } _y = parsedY; if (positionXY[2].ToString() != "N" && positionXY[2].ToString() != "S" && positionXY[2].ToString() != "W" && positionXY[2].ToString() != "E") { throw new MRSquadException("Rover initial direction must be N, S, W or E"); } _direction = positionXY[2].ToString()[0]; if (_x < 0 || _y < 0 || _x > planet._width || _y > planet._height) { throw new MRSquadException("Rover is out of surface boundaries"); } MoveRover(moveCommands); }
public Rover(IPlanetSurface planetSurface) { _planetSurface = planetSurface; _direction = new North(_planetSurface); }
public East(IPlanetSurface planetSurface) : base(planetSurface) { }
public RoverClient(IRoverInvoker roverInvoker, IPlanetSurface planetSurface) { _roverInvoker = roverInvoker; _rover = new Rover(planetSurface); }
public void Given() { PlanetSurface = new PlanetSurface(100); RoverInvoker = new RoverInvoker(); RoverClient = new RoverClient(RoverInvoker, PlanetSurface); }
protected BaseDirection(IPlanetSurface planetSurface) { PlanetSurface = planetSurface; }
public Squad(IPlanetSurface surface) { _surface = surface; }
public North(IPlanetSurface planetSurface) : base(planetSurface) { }
public South(IPlanetSurface planetSurface) : base(planetSurface) { }