namespace Composite { internal class Program { static void Main(string[] args) { Client client = new Client(); // simple leaf Leaf leaf = new Leaf(); Console.WriteLine("Client: I get a simple component:"); client.ClientCode(leaf); Console.WriteLine(""); // complex composites Composite tree = new Composite(); Composite branch1 = new Composite(); branch1.Add(new Leaf()); branch1.Add(new Leaf()); Composite branch2 = new Composite(); branch2.Add(new Leaf()); tree.Add(branch1); tree.Add(branch2); Console.WriteLine("Client: Now I've got a composite tree:"); client.ClientCode(tree); Console.WriteLine(""); Console.WriteLine("Client: I don't need to check the component classes even when managing the tree:"); client.ClientCode2(tree, leaf); } } }