/// <summary> /// This method outputs the heading and gives the user a choice /// of distance unit they would like to convert from and to. /// It lets the user know the distance is being converted, calculates /// the conversion and gives the user the result /// </summary> public void ConvertDistance() { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("\n Selecting units"); string[] choices = new string[] { FEET, METRES, MILES }; Console.WriteLine($"\n Please select a unit to convert from\n"); int choice = ConsoleHelper.SelectChoice(choices); FromUnit = choices[choice - 1]; Console.WriteLine($"\n You have selected {FromUnit}! "); Console.WriteLine($"\n Please select a unit to convert to\n"); choice = ConsoleHelper.SelectChoice(choices); ToUnit = choices[choice - 1]; Console.WriteLine($"\n You have selected {ToUnit}! "); FromDistance = ConsoleHelper.InputNumber($"\n Please enter the number of" + $" {FromUnit} you wish to convert to {ToUnit} > "); ConsoleHelper.OutputTitle($"\n Converting {FromUnit} to {ToUnit} "); CalculateDistance(); OutputDistance(); }
///<summary> /// Method calls methods to run the distance converter. ///</summary> public void run() { ConsoleHelper.OutputTitle(); ConsoleHelper.OutputHeadingFrom(); ConsoleHelper.DisplayChoices(); FromUnit = ConsoleHelper.SelectChoice(); ConsoleHelper.OutputHeadingTo(); ConsoleHelper.DisplayChoices(); ToUnit = ConsoleHelper.SelectChoice(); FromDistance = ConsoleHelper.getDistance(FromUnit); CalculateDistance(); ConsoleHelper.OutputResult(FromDistance, FromUnit, ToDistance, ToUnit); }