コード例 #1
0
        public void GivenTheRoverIsLocatedAt(string p0)
        {
            _planetSurface = new PlanetSurface(100);
            _roverInvoker = new RoverInvoker();
            _roverClient = new RoverClient(_roverInvoker, _planetSurface);

            StringAssert.Contains(p0, _roverClient.RoversCurrentLocation());
        }
コード例 #2
0
ファイル: MarsRover.cs プロジェクト: kaankazaz/MRSquad
        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);
        }
コード例 #3
0
ファイル: Rover.cs プロジェクト: philhack/MarsRoverKata
 public Rover(IPlanetSurface planetSurface)
 {
     _planetSurface = planetSurface;
     _direction = new North(_planetSurface);
 }
コード例 #4
0
ファイル: East.cs プロジェクト: philhack/MarsRoverKata
 public East(IPlanetSurface planetSurface)
     : base(planetSurface)
 {
 }
コード例 #5
0
ファイル: RoverClient.cs プロジェクト: philhack/MarsRoverKata
 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);
 }
コード例 #7
0
 protected BaseDirection(IPlanetSurface planetSurface)
 {
     PlanetSurface = planetSurface;
 }
コード例 #8
0
ファイル: Squad.cs プロジェクト: kaankazaz/MRSquad
 public Squad(IPlanetSurface surface)
 {
     _surface = surface;
 }
コード例 #9
0
ファイル: North.cs プロジェクト: philhack/MarsRoverKata
 public North(IPlanetSurface planetSurface)
     : base(planetSurface)
 {
 }
コード例 #10
0
ファイル: South.cs プロジェクト: philhack/MarsRoverKata
 public South(IPlanetSurface planetSurface)
     : base(planetSurface)
 {
 }