public void AddEngine(ICar car) { if (car is BMWCar) { BMWCar BMWCar = (BMWCar)car; BMWCar.Engine = "Petrol Engine"; Console.WriteLine("PetrolCarDecorator added Petrol Engine to the Car : " + car); } }
public void Run() { ICar bmwCar1 = new BMWCar(); bmwCar1.ManufactureCar(); Console.WriteLine(bmwCar1 + "\n"); DieselCarDecorator carWithDieselEngine = new DieselCarDecorator(bmwCar1); carWithDieselEngine.ManufactureCar(); Console.WriteLine(); ICar bmwCar2 = new BMWCar(); PetrolCarDecorator carWithPetrolEngine = new PetrolCarDecorator(bmwCar2); carWithPetrolEngine.ManufactureCar(); Console.ReadKey(); }