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}"); } } }
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); }