/** * This method gets the vehicles current amount of energy. */ private void getCurrentAmountOfEnergy(EnergySource i_EnergySource) { string message = (i_EnergySource is Fuel) ? "fuel amount" : "battery time left (in hours)"; ConsoleUtils.ClearConsoleAndWrite(string.Format("Enter the current {0}", message)); string userInput = Console.ReadLine(); float convertedInput = ConsoleUtils.CheckFloatInput(userInput, "Energy amount"); try { i_EnergySource.RefuelEnergy(convertedInput); } catch (Exception e) { ConsoleUtils.ClearConsoleAndWrite(e.Message); Console.WriteLine("Press any key to continue"); Console.ReadLine(); getCurrentAmountOfEnergy(i_EnergySource); } }
/** * This methods gets the current wheel pressure from the user */ private void getCurrentWheelPressure(List <Wheel> i_Wheels) { ConsoleUtils.ClearConsoleAndWrite("Enter the current pressure of the wheels"); string userInput = Console.ReadLine(); float convertedAirPressure = ConsoleUtils.CheckFloatInput(userInput, "Tire Pressure"); try { foreach (Wheel wheel in i_Wheels) { wheel.Inflate(convertedAirPressure); } } catch (ValueOutOfRangeException voore) { ConsoleUtils.ClearConsoleAndWrite(voore.Message); Console.WriteLine("Press any key to continue"); Console.ReadLine(); getCurrentWheelPressure(i_Wheels); } }