private void getWheelsCurrentPressure(Vehicle i_Vehicle) { string input; bool parseSucceeded = false; float currentPressure = 0; Console.Clear(); do { try { Console.WriteLine("Please enter your current wheels' air pressure: "); input = Console.ReadLine(); currentPressure = CustomConverter.ConvertStringToPositiveFloat(input); i_Vehicle.SetCurrentWheelsAir(currentPressure); parseSucceeded = true; } catch (FormatException e) { Console.WriteLine(e.Message); } catch (ValueOutOfRangeException e) { Console.WriteLine(e.Message); } catch (ArgumentException e) { Console.WriteLine(e.Message); } }while (!parseSucceeded); }
private void getCurrentEnergyState(Vehicle i_Vehicle) { string input; bool parseSucceeded = true; float currentState = 0; Console.Clear(); do { try { Console.WriteLine("Please enter your current energy amount: "); input = Console.ReadLine(); currentState = CustomConverter.ConvertStringToPositiveFloat(input); i_Vehicle.SetCurrentEnergyAmount(currentState); parseSucceeded = true; } catch (FormatException e) { parseSucceeded = false; Console.WriteLine(e.Message); } catch (ValueOutOfRangeException e) { parseSucceeded = false; Console.WriteLine(e.Message); } catch (ArgumentException e) { parseSucceeded = false; Console.WriteLine(e.Message); } }while (!parseSucceeded); }
private float getTrunkVolume() { bool isInputValid = false; float trunkVolume = 0; Console.Clear(); do { try { Console.WriteLine("Please enter your trunk volume:"); trunkVolume = CustomConverter.ConvertStringToPositiveFloat(Console.ReadLine()); isInputValid = true; } catch (FormatException e) { isInputValid = false; Console.WriteLine(e.Message); } catch (ValueOutOfRangeException e) { Console.WriteLine(e.Message); isInputValid = false; } }while (!isInputValid); return(trunkVolume); }