// 5 Method- The method refuel vehicle on gas public void Refuel(string i_LicenseNumber, eGasType i_FuelType, float i_FuelToAdd) { GarageCustomer customer = FindVehicleInGarage(i_LicenseNumber); GasTank gasTank = customer.Vehicle.GasTank; if (gasTank != null) { if (!gasTank.GasType.ToString().Equals(i_FuelType.ToString())) { throw new ArgumentException("Wrong fuel type"); // throw wrong gas exception. } else { if (i_FuelToAdd < 0 || i_FuelToAdd > gasTank.MaxCapacity - gasTank.CurrentAmount) { throw new ValueOutOfRangeException(gasTank.MaxCapacity - gasTank.CurrentAmount, 0); } else { gasTank.CurrentAmount += i_FuelToAdd; customer.Vehicle.EnergyLeft = gasTank.CurrentAmount / gasTank.MaxCapacity; } } } else { throw new ArgumentException("Cannot refuel with gas an electric vehicle"); } }
public Truck(string i_ModelName, string i_LicenseNumber, float i_EnergyLeft, bool i_DangerousSubstances, float i_TrunkCapacity) : base(i_ModelName, i_LicenseNumber, i_EnergyLeft) { GasVehicle = true; this.dangerousSubstances = i_DangerousSubstances; this.trunkCapacity = i_TrunkCapacity; GasTank = new GasTank(eGasType.Soler, 120); GasTank.CurrentAmount = EnergyLeft * GasTank.MaxCapacity; for (int i = 0; i < 16; i++) { Wheels.Add(new Wheel(28)); } }
public Motorcycle(string i_ModelName, string i_LicenseNumber, float i_EnergyLeft, eLicense i_LicenseType, int i_EngineVolume) : base(i_ModelName, i_LicenseNumber, i_EnergyLeft) { this.licenseType = i_LicenseType; this.engineVolume = i_EngineVolume; GasVehicle = true; GasTank = new GasTank(eGasType.Octan95, 7); GasTank.CurrentAmount = EnergyLeft * GasTank.MaxCapacity; for (int i = 0; i < 2; i++) { Wheels.Add(new Wheel(30)); } }
public Car(string i_ModelName, string i_LicensePlate, float i_EnergyLeft, eColor i_CarColor, eDoorsAmount i_AmountOfDoors) : base(i_ModelName, i_LicensePlate, i_EnergyLeft) { Dictionary <string, string> extraData = new Dictionary <string, string>(); extraData.Add("Color", i_CarColor.ToString()); extraData.Add("Number of doors", i_AmountOfDoors.ToString()); ExtraTypeData = extraData; GasTank = new GasTank(eGasType.Octan96, 60); GasVehicle = true; this.color = i_CarColor; GasTank.CurrentAmount = EnergyLeft * GasTank.MaxCapacity; this.amountOfDoors = i_AmountOfDoors; for (int i = 0; i < 4; i++) { Wheels.Add(new Wheel(32)); } }