public Truck(bool isElectric) { m_VehicleWheels = VehicleCreator.createWheels(k_NumberOfWheels, k_TruckMaxWheelPressure); m_VehicleEngine = VehicleCreator.CreateEngine(isElectric); PetrolEngine petrolEngine = m_VehicleEngine as PetrolEngine; petrolEngine.MaximumPetrolAmount = k_MaxPetrolLiterCapacity; petrolEngine.PetrolType = k_PetrolType; }
public Car(bool isElectric) { m_VehicleWheels = VehicleCreator.createWheels(k_NumberOfWheels, k_CarMaxWheelPressure); m_VehicleEngine = VehicleCreator.CreateEngine(isElectric); if (isElectric) { ElectricEngine electricEngine = m_VehicleEngine as ElectricEngine; electricEngine.MaximumBatteryHours = k_MaxBatteryHoursCapacity; } else { PetrolEngine petrolEngine = m_VehicleEngine as PetrolEngine; petrolEngine.MaximumPetrolAmount = k_MaxPetrolLiterCapacity; petrolEngine.PetrolType = k_PetrolType; } }