private static void Main(string[] args) { // Loop until user is given an estimate of their vaication cost while (true) { // Request user input Console.WriteLine("Please enter your veichle of choice eg. Car"); var veichle = Console.ReadLine().ToLower(); Console.WriteLine("Please enter the distance to your destination eg. 5502"); var distance = Console.ReadLine().ToLower(); // Validate user input if (!string.IsNullOrEmpty(veichle) && !string.IsNullOrEmpty(distance)) { // Instantiate cost calculator VacationCostCalculator calculator = new VacationCostCalculator { DistanceToDestination = double.Parse(distance) }; // Check if input is unsupported (i know this isn't ideal, but at the time of writing i just had spent way to much time on this section) //** TODO **// ;-) if (calculator.CostOfVacation(veichle) is not null) { Console.WriteLine(calculator.CostOfVacation(veichle)); break; } // Error message on bad user input Console.WriteLine("You provided a non-supported veichle, try again!"); } } }
static void Main(string[] args) { var interpreter = new CommandLineInterpreter(args); if (interpreter.VacationCostModel == null) { return; } var calculator = new VacationCostCalculator(interpreter.VacationCostModel); var result = calculator.CostOfVacation(); Console.WriteLine(result); Console.ReadLine(); }
static void Main(string[] args) { if(args.Length < 2) { Console.WriteLine("Not enough input arguments to run this program"); Console.ReadLine(); } else { var transportMethod = args[0]; var distance = args[1]; var calculator = new VacationCostCalculator { DistanceToDestination = double.Parse(distance) }; var result = calculator.CostOfVacation(transportMethod); Console.WriteLine(result); Console.ReadLine(); } }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Not enough input arguments to run this program"); Console.ReadLine(); } else { var transportMethod = args[0]; var distance = args[1]; var calculator = new VacationCostCalculator { DistanceToDestination = double.Parse(distance) }; var result = calculator.CostOfVacation(transportMethod); Console.WriteLine(result); Console.ReadLine(); } }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Not enough input arguments to run this program"); Console.ReadLine(); return; } var transportMethod = args[0]; var distance = args[1]; var calculator = new VacationCostCalculator(); var result = calculator.CostOfVacation(transportMethod, distance); Console.WriteLine(result); Console.ReadLine(); }