示例#1
0
        static void Main(string[] args)
        {
            MarsRover marsRover = null;

            while (marsRover == null)
            {
                try
                {
                    marsRover = new MarsRover(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Plateau input is not valid, please try again. Error: {e.Message}");
                }
            }

            while (true)
            {
                try
                {
                    marsRover.UpdateValues(Console.ReadLine(), Console.ReadLine());
                    Console.WriteLine(marsRover.RunAndGetResult());
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Run failed, please try again. Error: {e.Message}");
                }
            }
        }
示例#2
0
        private void InitialiseRover(string initialPositionLine, string navigationCommandsLine)
        {
            var initialPosition  = GetCoordinates(initialPositionLine);
            var initialDirection = GetInitialDirection(initialPositionLine);
            var orientation      = new Orientation(initialDirection);
            var rover            = new MarsRover(initialPosition, orientation, navigationCommandsLine);

            _marsRovers.Add(rover);
        }