Ejemplo n.º 1
0
        static void Main()
        {
            // Create ConcreteComponent and two Decorators
            ConcreteComponent  c  = new ConcreteComponent();
            ConcreteDecoratorA d1 = new ConcreteDecoratorA();
            ConcreteDecoratorB d2 = new ConcreteDecoratorB();

            ChristmasTree ct = new ChristmasTree();

            ToyChristmasTreeDecorator     td = new ToyChristmasTreeDecorator();
            GarlandChristmasTreeDecorator gd = new GarlandChristmasTreeDecorator();

            td.SetTree(ct);
            gd.SetTree(ct);
            td.DecotateChristmasTree();
            gd.DecotateChristmasTree();
            // Link decorators
            d1.SetComponent(c);
            d2.SetComponent(d1);

            d2.Operation();

            // Wait for user
            Console.Read();
        }
Ejemplo n.º 2
0
        static void Main()
        {
            // Create ConcreteComponent and two Decorators
            ChristmasTree tree = new ChristmasTree();
            NonLightDecorationsDecorator d1 = new NonLightDecorationsDecorator();
            GarlandsDecorator            d2 = new GarlandsDecorator();

            // Link decorators
            d1.SetTree(tree);
            d2.SetTree(tree);

            d1.SetAllDecorations(10);
            d2.SetAllDecorations(2);

            // Wait for user
            Console.Read();
        }
Ejemplo n.º 3
0
 public void SetTree(ChristmasTree _tree)
 {
     tree = _tree;
 }
Ejemplo n.º 4
0
 public void SetTree(ChristmasTree tree)
 {
     _tree = tree;
 }
Ejemplo n.º 5
0
 public void SetTree(ChristmasTree tree)
 {
     this.tree = tree;
 }