Exemple #1
0
        public void RoverWithSouthCardinalRotateRightReturnsWestCardinal()
        {
            var rover = new Rover(5, 5, 'S');

            rover.ChangeOrientation('R');

            rover.CardinalPoint.ShouldBe('W');
        }
Exemple #2
0
        public void RoverWithSouthCardinalRotateLeftReturnsEastCardinal()
        {
            var rover = new Rover(5, 5, 'S');

            rover.ChangeOrientation('L');

            rover.CardinalPoint.ShouldBe('E');
        }
        private void ProcessRoverInstructions(string roverInstructions, Rover rover)
        {
            foreach (var roverInstruction in roverInstructions)
            {
                switch (roverInstruction)
                {
                case 'L':
                case 'R':
                    rover.ChangeOrientation(roverInstruction);
                    break;

                case 'M':
                    rover.Move();
                    ValidateRoverPositionOnPlateau(rover);
                    break;

                default:
                    throw new ArgumentException("unable to process MarsRover instructions.");
                }
            }
        }