public void FuelGasVehicle(string i_ExistingVehicleNumber, FuelTank.eFuelType i_FuelType, float i_AmountOfLitersToFuel) { VehicleInTreatmentDetails vehicleToFuel; m_VehiclesInGarageByNumber.TryGetValue(i_ExistingVehicleNumber, out vehicleToFuel); if (vehicleToFuel.TheVehicleInTreatment.EngineType == Vehicle.eVehicleEngineType.ElectricEngine) { throw new ArgumentException(string.Format("The vehicle with number {0} is electric, cannot perform fuel action", i_ExistingVehicleNumber)); } else { if (vehicleToFuel.TheVehicleInTreatment is GasCar) { (vehicleToFuel.TheVehicleInTreatment as GasCar).FuelGasCar(i_FuelType, i_AmountOfLitersToFuel); } if (vehicleToFuel.TheVehicleInTreatment is GasMotorcycle) { (vehicleToFuel.TheVehicleInTreatment as GasMotorcycle).FuelGasMotorcycle(i_FuelType, i_AmountOfLitersToFuel); } if (vehicleToFuel.TheVehicleInTreatment is GasTruck) { (vehicleToFuel.TheVehicleInTreatment as GasTruck).FuelGasTruck(i_FuelType, i_AmountOfLitersToFuel); } } }
private void refuel() { string stringToPrint; float amountOfFuelToAdd; FuelTank.eFuelType fuelType = new FuelTank.eFuelType(); string licenseNumber; stringToPrint = "Please enter the vehicle number"; UI.PrintString(stringToPrint.ToString()); licenseNumber = UI.ReadStringFromUser(); stringToPrint = "Please enter the fuel type you want to add"; UI.PrintString(stringToPrint.ToString()); fuelType = (FuelTank.eFuelType)UI.GetInputAccordingToEnum(fuelType); stringToPrint = "Please enter the amount of fuel you want to add"; UI.PrintString(stringToPrint.ToString()); amountOfFuelToAdd = UI.ReadFloatFromUser(); try { r_Garage.Refuel(licenseNumber, amountOfFuelToAdd, fuelType); } catch (Exception exception) { UI.PrintString(exception.Message); } }
public GasTruck(float i_MaxFuelCapacity, Truck.eTruckCargo i_TruckCargo, FuelTank.eFuelType i_FuelType, float i_VolumeCapacity, float i_MaximumAllowedCargoWeight, string i_VehicleNumber, string i_VehicleModel, int i_NumberOfWheels, string i_WheelManufacturerName, float i_MaxAllowedAirPressure) : base(i_VolumeCapacity, i_TruckCargo, i_MaximumAllowedCargoWeight, i_VehicleNumber, i_VehicleModel, i_NumberOfWheels, i_WheelManufacturerName, i_MaxAllowedAirPressure) { this.m_FuelTank = new FuelTank(i_MaxFuelCapacity, i_FuelType); this.m_EngineType = Vehicle.eVehicleEngineType.GasEngine; }
public GasCar(float i_MaxFuelCapacity, FuelTank.eFuelType i_FuelType, Car.eCarColorOptions i_CarColor, Car.eNumberOfDoors i_NumberOfDoors, string i_VehicleNumber, string i_VehicleModel, int i_NumberOfWheels, string i_WheelManufacturerName, float i_MaxAllowedAirPressure) : base(i_CarColor, i_NumberOfDoors, i_VehicleNumber, i_VehicleModel, i_NumberOfWheels, i_WheelManufacturerName, i_MaxAllowedAirPressure) { this.m_FuelTank = new FuelTank(i_MaxFuelCapacity, i_FuelType); this.m_EngineType = Vehicle.eVehicleEngineType.GasEngine; }
public void Refuel(string i_LicenseNumber, float i_AmountToAdd, FuelTank.eFuelType i_FuelType) { EnergySource.eEnergySourceType energyType = EnergySource.eEnergySourceType.Fuel; checkIfVehicleInGarage(i_LicenseNumber); checkIfFillEnergyActionSuitableToEnergySource(i_LicenseNumber, energyType); (r_Vehicles[i_LicenseNumber].Vehicle.EnergySource as FuelTank).Refuel(i_AmountToAdd, i_FuelType); }
public GasMotorcycle(float i_MaximumFuelCapacity, FuelTank.eFuelType i_FuelType, eMotorcycleLicenseType i_MotorcycleLicenseType, int i_EngineCapacity, string i_VehicleNumber, string i_VehicleModel, int i_NumberOfWheels, string i_WheelManufacturerName, float i_MaxAllowedAirPressure) : base(i_MotorcycleLicenseType, i_EngineCapacity, i_VehicleNumber, i_VehicleModel, i_NumberOfWheels, i_WheelManufacturerName, i_MaxAllowedAirPressure) { this.m_FuelTank = new FuelTank(i_MaximumFuelCapacity, i_FuelType); this.m_EngineType = eVehicleEngineType.GasEngine; }
public void FillFuelInVehicle(string i_PlateNumber, FuelTank.eFuelType i_FuelType, float i_FuelToFill) { GarageVehicle vehicleToFillFuel = getVehicleFromDictionary(i_PlateNumber); if (vehicleToFillFuel == null) { throw new ArgumentException(string.Format("Vehicle with plate number {0} not found ", i_PlateNumber)); } if (!(vehicleToFillFuel.Vehicle.DetailsOfVehicle.energyType is FuelTank)) { throw new ArgumentException("Energy type is incompatible"); } (vehicleToFillFuel.Vehicle.DetailsOfVehicle.energyType as FuelTank).FillTank(i_FuelToFill, i_FuelType); }
public void FuelGasMotorcycle(FuelTank.eFuelType i_FuelType, float i_AmountOfLitersToFuel) { if (i_FuelType != this.m_FuelTank.FuelType) { throw new ArgumentException(string.Format("Error: The Motorcycle's fuel type is {0}, and you chose {1}", this.m_FuelTank.FuelType.ToString(), i_FuelType.ToString())); } else if (this.m_FuelTank.CurrentFuelAmmount + i_AmountOfLitersToFuel > this.m_FuelTank.MaximumFuelCapacity) { string errorMsg = string.Format("Error: The amount to fuel exceeds the maximum capacity, the maximum amount to fuel is {0}", this.m_FuelTank.MaximumFuelCapacity - this.m_FuelTank.CurrentFuelAmmount); throw new ValueOutOfRangeException(this.m_FuelTank.MaximumFuelCapacity, 0, errorMsg); } else { this.m_FuelTank.CurrentFuelAmmount += i_AmountOfLitersToFuel; this.RemainPercentageEnergy = this.m_FuelTank.CurrentFuelAmmount / this.m_FuelTank.MaximumFuelCapacity; } }
private static void fillFuelInVehicle() { float fuelToFill; Console.WriteLine("Please enter a plate number: "); string plateNumber = Console.ReadLine(); FuelTank.eFuelType fuelType = (FuelTank.eFuelType)getUserChoiceFromEnumValues(typeof(FuelTank.eFuelType)); Console.WriteLine("Please enter how many liters of fuel to add: "); string fuelAmountAsString = Console.ReadLine(); if (!float.TryParse(fuelAmountAsString, out fuelToFill)) { throw new FormatException(); } s_Garage.FillFuelInVehicle(plateNumber, fuelType, fuelToFill); Console.WriteLine("Fuel was added successfully"); }
public void FuelOrChargeVehicle(string i_PlateNumber, Energy.eEnergyType i_EnergyType, float i_AmountToFill) { Energy.eEnergyType m_EnergyType = i_EnergyType; GarageVehicle vehicleToFillEnergy = getVehicleFromDictionary(i_PlateNumber); if (vehicleToFillEnergy == null) { throw new ArgumentException(string.Format("Vehicle with registration plate number {0} not found ", i_PlateNumber)); } else if (vehicleToFillEnergy.Vehicle.EnergyType is ElectricBattery) { (vehicleToFillEnergy.Vehicle.EnergyType as ElectricBattery).Charge(i_AmountToFill); } else if (vehicleToFillEnergy.Vehicle.EnergyType is FuelTank) { FuelTank.eFuelType m_fuelType = (FuelTank.eFuelType)Enum.Parse(typeof(FuelTank.eFuelType), m_EnergyType.ToString()); (vehicleToFillEnergy.Vehicle.EnergyType as FuelTank).FillTank(i_AmountToFill, m_fuelType); } else { throw new ArgumentException("Energy type is incompatible"); } }