Ejemplo n.º 1
0
 public void AddEngine(ICar car)
 {
     if (car is BMWCar)
     {
         BMWCar BMWCar = (BMWCar)car;
         BMWCar.Engine = "Diesel Engine";
         Console.WriteLine("DieselCarDecorator added Diesel Engine to the Car : " + car);
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            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();
        }