public void AddFuelToVehicle(string i_PlateNumber, float i_FuelAmount, FuelVehicle.eFuelType i_FuelType) { FuelVehicle fuelVehicle = null; foreach (KeyValuePair <Vehicle, Owner> vehicle in m_VehiclesInGarage) { if (vehicle.Key.LicensePlateNumber == i_PlateNumber) { fuelVehicle = vehicle.Key as FuelVehicle; if (fuelVehicle == null) { throw new ArgumentException("This vehicle does not match this type of operation"); } else { fuelVehicle.AddFuel(i_FuelAmount, i_FuelType); break; } } } if (fuelVehicle == null) { throw new ArgumentException(string.Format("Vehicle with this license plates does not exists in the Garage")); } }
private void getFuelToAdd(out FuelVehicle.eFuelType o_FuelType, out float o_FuelToAdd) { PrintingUtils.PrintListOfEnum("Please write below the fuel type:", typeof(FuelVehicle.eFuelType)); bool isValid = Enum.TryParse(Console.ReadLine(), out o_FuelType) && Enum.IsDefined(typeof(FuelVehicle.eFuelType), o_FuelType); if (isValid == false) { throw new FormatException("Fail parsing fuel type"); } Console.WriteLine("Please insert the amount of fuel you would like to add: "); bool isParse = float.TryParse(Console.ReadLine(), out o_FuelToAdd); if (isParse == false) { throw new FormatException("Fail parsing the amount of fuel to add"); } }
public void refuelingFuelVehicle(string i_LicensePlate, FuelVehicle.eFuelType i_FuelType, float i_AmountToRefuel) { if (m_AllVehiclesInTheGarage.ContainsKey(i_LicensePlate)) { Vehicle vehicleToFuel = m_AllVehiclesInTheGarage[i_LicensePlate].m_Vehicle; if (vehicleToFuel is FuelVehicle) { ((FuelVehicle)vehicleToFuel).refueling(i_FuelType, i_AmountToRefuel); } else { throw new ArgumentException("This vehicle isn't a fuel vehicle"); } } else { throw new ArgumentException("This Vehicle isn't in the garage"); } }
private void addFuelToVehicle() { string plateNumber = getLicensePlateNumber(); float fuelAmount = getFuelAmount(); FuelVehicle.eFuelType typeOfFuel = getFuelType(); try { r_Garage.AddFuelToVehicle(plateNumber, fuelAmount, typeOfFuel); } catch (ValueOutOfRangeException valueOutOfRange) { Console.WriteLine(valueOutOfRange.Message); } catch (ArgumentException logicError) { Console.WriteLine(logicError.Message); } }
public void fillFuel() { string licensePlate = m_UserInputs.getLicensePlate(); FuelVehicle.eFuelType fuelType = m_UserInputs.getFuelType(); float amountToRefuel = m_UserInputs.getAmountToRefuel(); try { m_Garage.refuelingFuelVehicle(licensePlate, fuelType, amountToRefuel); m_UserInputs.suceededToFillFuel(); } catch (ArgumentException e) { Console.WriteLine(e.Message); } catch (ValueOutOfRangeException e) { Console.WriteLine(e.Message); } System.Console.ReadLine(); }
public FuelMotorcycle(Motorcycle i_Motorcycle, FuelVehicle.eFuelType i_FuelType, float i_CurrentAmountOfFuel, string i_Model, string i_LicensePlateNumber, float i_PercentOfRemainingEnergy, List <Tire> i_Tires) : base(i_FuelType, i_CurrentAmountOfFuel, i_Model, i_LicensePlateNumber, i_PercentOfRemainingEnergy, i_Tires, k_MaxAmountOfFuel) { m_Properties.Add(new Property("Max amount of fuel", typeof(float)), k_MaxAmountOfFuel); m_Motorcycle = i_Motorcycle; }
public static FuelTruck createFuelTruck(Truck i_Truck, FuelVehicle.eFuelType i_FuelType, float i_CurrentAmountOfFuel, string i_Model, string i_LicensePlateNumber, float i_PercentOfRemainingEnergy, List <Tire> i_Tires) { FuelTruck newFuelTruck = new FuelTruck(i_Truck, i_FuelType, i_CurrentAmountOfFuel, i_Model, i_LicensePlateNumber, i_PercentOfRemainingEnergy, i_Tires); return(newFuelTruck); }
public static FuelMotorcycle createFuelMotorcycle(Motorcycle i_Motorcycle, FuelVehicle.eFuelType i_FuelType, float i_CurrentAmountOfFuel, string i_Model, string i_LicensePlateNumber, float i_PercentOfRemainingEnergy, List <Tire> i_Tires) { FuelMotorcycle newFuelMotorcycle = new FuelMotorcycle(i_Motorcycle, i_FuelType, i_CurrentAmountOfFuel, i_Model, i_LicensePlateNumber, i_PercentOfRemainingEnergy, i_Tires); return(newFuelMotorcycle); }
public static FuelCar createFuelCar(Car i_Car, FuelVehicle.eFuelType i_FuelType, float i_CurrentAmountOfFuel, string i_Model, string i_LicensePlateNumber, float i_PercentOfRemainingEnergy, List <Tire> i_Tires) { FuelCar newFuelCar = new FuelCar(i_Car, i_FuelType, i_CurrentAmountOfFuel, i_Model, i_LicensePlateNumber, i_PercentOfRemainingEnergy, i_Tires); return(newFuelCar); }
public FuelVehicle.eFuelType getFuelType() { FuelVehicle.eFuelType fuelType = (FuelVehicle.eFuelType)getValidInt(FUEL_TYPE, 1, 4); return(fuelType); }