예제 #1
0
 public void SetUp()
 {
     _position            = new Position();
     _positionInfo        = new PositionInfo();
     _rover               = new TechTest.Rover(_position, _positionInfo);
     _equivalenceCommands = new Dictionary <string, Commands>
     {
         { "L", Commands.TurnLeft },
         { "R", Commands.TurnRight },
         { "F", Commands.Forward }
     };
 }
        public static void Main()
        {
            var rover = new TechTest.Rover(new Position(), new PositionInfo());
            var equivalenceCommands = new Dictionary <string, Commands>
            {
                { "L", Commands.TurnLeft },
                { "R", Commands.TurnRight },
                { "F", Commands.Forward }
            };

            while (true)
            {
                var userInput = Console.ReadLine()?.ToUpper();

                if (equivalenceCommands.TryGetValue(userInput, out var command))
                {
                    rover.Move(command);
                }
                else
                {
                    Console.WriteLine("Invalid Command");
                }
            }
        }