private static void fuelVehicle(Ex03.GarageLogic.Garage i_Garage) { Console.WriteLine("Please enter the vehicles license number"); string licenseNumber = InputValidation.GetCarLicense(); bool isCarExists = i_Garage.CarIsAlreadyInGarage(licenseNumber); if (!isCarExists) { Console.WriteLine("Could not locate car in the garage. Please try again later."); } else { string selectMsg = string.Format( @"Please select type of Fuel/Electric you would like to fill in your vehicle {0}", i_Garage.GetEnergyTypes()); Console.WriteLine(selectMsg); int selection = InputValidation.GetIntValueInRange(1, i_Garage.GetNumberOfEnergyType()); Console.WriteLine("Please enter the amount you would like to fill (in Litres)"); float amountToFill = InputValidation.GetFloatValueInRange(0, float.MaxValue); try { i_Garage.FillEnergy(licenseNumber, selection, amountToFill); } catch (ArgumentException e1) { Console.WriteLine(e1.Message); } catch (Ex03.GarageLogic.ValueOutOfRangeException e2) { Console.WriteLine(e2.Message); } } }
private static void chargeVehicle(Ex03.GarageLogic.Garage i_Garage) { Console.WriteLine("Please enter the vehicles license number"); string licenseNumber = InputValidation.GetCarLicense(); bool isCarExists = i_Garage.CarIsAlreadyInGarage(licenseNumber); if (!isCarExists) { Console.WriteLine("Could not locate car in the garage. Please try again later."); } else { Console.WriteLine("Please enter the amount you would like to fill (in minutes)"); float amountToFill = InputValidation.GetFloatValueInRange(0, float.MaxValue); try { i_Garage.FillEnergy(licenseNumber, 5, amountToFill / 60); } catch (ArgumentException e1) { Console.WriteLine(e1.GetType() + ": Wrong type of Energy. Better luck next time."); } catch (Ex03.GarageLogic.ValueOutOfRangeException e2) { Console.WriteLine(e2.GetType() + ": Invalid amount to fill. Better luck next time."); } } }