Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. interface IComponent
  2. {
  3.     void operation();
  4. }
  5. class Leaf : IComponent
  6. {
  7.     public void operation()
  8.     {
  9.         Console.WriteLine("display leaf "+this);
  10.     }
  11. }
  12. class Composite : IComponent
  13. {
  14.     private List<IComponent> _children = new List<IComponent>();
  15.  
  16.     public void operation()
  17.     {
  18.         Console.WriteLine("display leaf " + this);
  19.     }
  20.  
  21.     public void AddChild(IComponent component)
  22.     {
  23.         _children.Add(component);
  24.     }
  25.  
  26.     public void RemoveChild(IComponent component)
  27.     {
  28.         _children.Remove(component);
  29.     }
  30.  
  31.     public List<IComponent> GetChild()
  32.     {
  33.         return _children;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement