public void DisplayInformation() { StringBuilder informations = new StringBuilder(); informations.AppendLine("License number : " + this.LicenseNumber); informations.AppendLine("Model Name : " + this.m_ModelName); informations.AppendLine("Owner Name : " + this.m_OwnerName); informations.AppendLine("Status : " + this.m_Status); if (EnergySystem is FuelBase) { FuelBase fuelBase = (FuelBase)EnergySystem; informations.AppendLine("Fuel type: " + fuelBase.FuelType); informations.AppendLine("Remaining fuel percentage: " + m_RemainingEnergyPercentage); } else if (EnergySystem is ElectricBase) { informations.AppendLine("Remaining battery percentage: " + m_RemainingEnergyPercentage); } else { informations.AppendLine("Remaining energy percentage: " + m_RemainingEnergyPercentage); } int i = 1; foreach (Wheel wheel in m_Wheels) { informations.AppendLine("Manufacturer Name of wheel " + i + " : " + wheel.ManufacturerName); informations.AppendLine("Air pressure of wheel " + i + " : " + wheel.CurrentAirPressure); i++; } informations.AppendLine(this.ToString()); Console.WriteLine(informations); }
public Truck(string i_ModelName, string i_LicenseNumber, string i_OwnerName, string i_OwnerPhoneNumber, List <Wheel> i_wheels, bool i_IsCooled, float i_CargoVolume, EnergySystem i_energySystem) : base(i_ModelName, i_LicenseNumber, i_OwnerName, i_OwnerPhoneNumber, i_wheels, i_energySystem) { m_IsCooled = i_IsCooled; m_CargoVolume = i_CargoVolume; EnergySystem = new FuelBase(EnergySystem.MaxAmountOfEnergy, eFuelType.Solar); // set somehow }
public void RefuelVehicle(string i_LicenseNumber, float i_AmountToFill, eFuelType i_fuelType) { Vehicle vehicle = FindVehicle(i_LicenseNumber); FuelBase fuelBase = (FuelBase)vehicle.EnergySystem; eFuelType fuelType = fuelBase.FuelType; if (i_fuelType != fuelType) { throw new ArgumentException("Wrong type of fuel"); } fuelBase.RefillEnergy(i_AmountToFill); vehicle.RemainingEnergyPercentage = (fuelBase.CurrentAmountOfEnergy / fuelBase.MaxAmountOfEnergy) * 100; }