static void Main(string[] args) { Composite root=new Composite("root"); root.Add(new Leaf("Leag A")); root.Add(new Leaf("Leaf B")); Composite comp = new Composite("Composite X"); comp.Add(new Leaf("Composite XA")); comp.Add(new Leaf("Composite XB")); root.Add(comp); root.Add(new Leaf("C")); root.DisPlay(1); Console.ReadKey(); }
static void Main(string[] args) { Composite root = new Composite("root"); root.Add(new Leaf("A")); root.Add(new Leaf("B")); Composite composit1 = new Composite("composite1"); composit1.Add(new Leaf("A1")); composit1.Add(new Leaf("B1")); root.Add(composit1); root.Add(new Leaf("C")); root.Display(1); }
static void Main(string[] args) { Composite root = new Composite("root"); root.Add(new Leaf("Leaf A")); root.Add(new Leaf("Leaf B")); Composite comp = new Composite("Composite X"); comp.Add(new Leaf("Leaf XA")); comp.Add(new Leaf("Leaf XB")); root.Add(comp); Composite comp2 = new Composite("Composite XY"); comp2.Add(new Leaf("Leaf XYA")); comp2.Add(new Leaf("Leaf XYB")); comp.Add(comp2); root.Add(new Leaf("Leaf C")); Leaf leaf = new Leaf("Leaf D"); root.Add(leaf); root.Remove(leaf); root.Display(1); Console.Read(); }