internal static void UsageMethod() { Composite root = new Composite("root"); root.Add(new Leaf("Branch 1A")); root.Add(new Leaf("Branch 1B")); Composite comp = new Composite("Composite X"); comp.Add(new Leaf("Branch 2A")); comp.Add(new Leaf("Branch 2B")); root.Add(comp); root.Add(new Leaf("Branch C")); Leaf branch = new Leaf("Branch D"); root.Add(branch); root.Remove(branch); root.Display(1); }
static void Main() { //Top of the tree Composite root = new Composite("root"); root.Add(new Leaf("Leaf A")); root.Add(new Leaf("Leaf B")); //Branch Composite comp = new Composite("Composite X"); comp.Add(new Leaf("Leaf XA")); comp.Add(new Leaf("Leaf XB")); root.Add(comp); root.Add(new Leaf("Leaf C")); Leaf leaf = new Leaf("Leaf D"); root.Add(leaf); Leaf leaf2 = new Leaf("Leaf Z"); root.Add(leaf2); root.Remove(leaf); //Recursively display tree root.FetchChildren(1); Console.ReadKey(); }
public void UsageMethod() { Composite root = new Composite("root"); root.Add(new Leaf("Branch 1A")); root.Add(new Leaf("Branch 1B")); Composite comp = new Composite("Composite X"); comp.Add(new Leaf("Branch 2A")); comp.Add(new Leaf("Branch 2B")); root.Add(comp); root.Add(new Leaf("Branch C")); Leaf branch = new Leaf("Branch D"); root.Add(branch); root.Remove(branch); root.Display(1); }