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(); }
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(); }
public void SetTree(ChristmasTree _tree) { tree = _tree; }
public void SetTree(ChristmasTree tree) { _tree = tree; }
public void SetTree(ChristmasTree tree) { this.tree = tree; }