public static void Main() { Console.WriteLine(Constants.WELCOME); var rover = RoverPosition.GetInstance(); PrintRoverPosition(rover.RoverPositionX, rover.RoverPositionY, rover.RoverFacingPosition); while (true) { Console.WriteLine(Constants.COMMAND_PROMPT); try { var command = Console.ReadLine().Trim(); var isValid = ValidateCommand(command); if (!isValid) { Console.WriteLine(Constants.INVALID_COMMAND); } else { ExecuteCommand(command, rover); } } catch (Exception ex) { Console.WriteLine($"There was an error and the application will terminate. {ex.Message}"); System.Environment.Exit(1); } } }
public static RoverPosition GetInstance() { if (instance == null) { instance = new RoverPosition(); } return(instance); }