Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface IComponent
- {
- void operation();
- }
- class Leaf : IComponent
- {
- public void operation()
- {
- Console.WriteLine("display leaf "+this);
- }
- }
- class Composite : IComponent
- {
- private List<IComponent> _children = new List<IComponent>();
- public void operation()
- {
- Console.WriteLine("display leaf " + this);
- }
- public void AddChild(IComponent component)
- {
- _children.Add(component);
- }
- public void RemoveChild(IComponent component)
- {
- _children.Remove(component);
- }
- public List<IComponent> GetChild()
- {
- return _children;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement