Exemple #1
0
        public void RotateLeftFromNorth_ExpectedWest()
        {
            // Arrange
            _rover.SetHeading(Heading.North);

            // Act
            _rover.RotateLeft();

            // Assert
            Assert.IsTrue(_rover.GetHeading() == Heading.West);
        }
 public void Execute(string commands, IRover rover)
 {
     foreach (var command in commands)
     {
         if (command == 'M')
             rover.MoveForward();
         else if (command == 'L')
             rover.RotateLeft();
         else
             rover.RotateRight();
     }
 }
Exemple #3
0
 public void Execute(string commands, IRover rover)
 {
     foreach (var command in commands)
     {
         if (command == 'M')
         {
             rover.MoveForward();
         }
         else if (command == 'L')
         {
             rover.RotateLeft();
         }
         else
         {
             rover.RotateRight();
         }
     }
 }
Exemple #4
0
        public void CommandRover(string directions)
        {
            foreach (var direction in directions)
            {
                switch (direction)
                {
                case 'L':
                    _rover.RotateLeft();
                    break;

                case 'R':
                    _rover.RotateRight();
                    break;

                case 'M':
                    _rover.Move();
                    break;
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Execute command if its one of the { 'L', 'R', 'M' }
        /// Rover will not move further if it hit the boundary
        /// </summary>
        /// <param name="rover"></param>
        /// <param name="command"></param>
        private void ExecuteCommand(IRover rover, char command)
        {
            switch (command)
            {
            case 'L':
                rover.RotateLeft();
                break;

            case 'R':
                rover.RotateRight();
                break;

            case 'M':
                if (!_plateau.OutOfBound(rover.GetDest().X, rover.GetDest().Y))
                {
                    rover.Move();
                }
                break;

            default:
                throw new InvalidInputException(command + " is not valid input for command!");
            }
        }
Exemple #6
0
 public void RotateRoverLeft(IRover rover)
 {
     rover.RotateLeft();
 }
Exemple #7
0
 public void Execute(IRover rover)
 {
     rover.RotateLeft();
 }