Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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();
         }
     }
 }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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!");
            }
        }
Ejemplo n.º 6
0
 public void RotateRoverLeft(IRover rover)
 {
     rover.RotateLeft();
 }
Ejemplo n.º 7
0
 public void Execute(IRover rover)
 {
     rover.RotateLeft();
 }