Exemple #1
0
        /// <summary>
        /// Rotates the rover based on the input received
        /// </summary>
        /// <param name="command">"L" or "R" taken from input</param>
        public void ProcessCommands()
        {
            foreach (char command in inputCommand)
            {
                switch (command)
                {
                case 'L':
                    dir.TurnLeft();
                    break;

                case 'R':
                    dir.TurnRight();
                    break;

                case 'M':
                    MoveRover();
                    RoverIsInBoundaries();
                    break;

                default:
                    Console.WriteLine("Wrong command given!");
                    break;
                }
            }
        }
Exemple #2
0
        public void Command(params char[] commands)
        {
            ValidateCommands(commands);
            for (var i = 0; i < COMMANDLENGTH; i++)
            {
                var command = commands[i];
                switch (command)
                {
                case 'f':
                    Position = World.Move(Position, Direction);
                    break;

                case 'b':
                    Position = World.Move(Position, Direction.Reverse().Reverse());
                    break;

                case 'r':
                    Direction = Direction.TurnRight();
                    break;

                case 'l':
                    Direction = Direction.TurnLeft();
                    break;

                default:
                    break;
                }
            }
        }
 public void RotateLeft()
 {
     Direction.TurnLeft();
 }