示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Decorator design pattern!");

            var legacyOldCar = new LegacyOldCar();

            Console.WriteLine("Name: " + legacyOldCar.GetName());
            Console.WriteLine("Cost: " + legacyOldCar.GetCost());

            var legacyCarWithNewIndicator = new LegacyOldCarWithNewIndicator(legacyOldCar);

            Console.WriteLine("Name: " + legacyCarWithNewIndicator.GetName());
            Console.WriteLine("Cost: " + legacyCarWithNewIndicator.GetCost());

            var legacyCarWithNewIndicatorAndWheel = new LegacyOldCarWithNewIndicatorAndWheel(legacyOldCar);

            Console.WriteLine("Name: " + legacyCarWithNewIndicatorAndWheel.GetName());
            Console.WriteLine("Cost: " + legacyCarWithNewIndicatorAndWheel.GetCost());
        }
示例#2
0
 public LegacyOldCarWithNewIndicator(LegacyOldCar legacyOldCar) : base(legacyOldCar)
 {
 }
示例#3
0
 public LegacyOldCarWithNewIndicatorAndWheel(LegacyOldCar legacyOldCar) : base(legacyOldCar)
 {
 }
示例#4
0
 public LegacyOldCarDecorator(LegacyOldCar legacyOldCar)
 {
     this._legacyOldCar = legacyOldCar;
 }