Esempio n. 1
0
        static void Main(string[] args)
        {
            Component root = new Composite("ROOT");
            Component branch1 = new Composite("BR1");
            Component branch2 = new Composite("BR2");
            Component leaf1 = new Leaf("L1");
            Component leaf2 = new Leaf("L2");

            root.Add(branch1);
            root.Add(branch2);
            branch1.Add(leaf1);
            branch2.Add(leaf2);
            root.Operation();
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Component root    = new Composite("ROOT");
            Component branch1 = new Composite("BR1");
            Component branch2 = new Composite("BR2");
            Component leaf1   = new Leaf("L1");
            Component leaf2   = new Leaf("L2");

            root.Add(branch1);
            root.Add(branch2);
            branch1.Add(leaf1);
            branch2.Add(leaf2);
            root.Operation();
            Console.ReadLine();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Composite root = new Composite("Root");

            root.Add(new Leaf("Leaf1"));
            root.Add(new Leaf("Leaf2"));

            Composite compositeNode = new Composite("compositeNode");

            compositeNode.Add(new Leaf("Leaf1"));
            compositeNode.Add(new Leaf("Leaf2"));
            root.Add(compositeNode);

            root.Display(1);
            Console.Read();
        }
        public CompositeForm()
        {
            InitializeComponent();

            Composite root = new Composite("Inventory");

            root.Add(new Leaf("Food"));
            root.Add(new Leaf("Sword"));
            Composite bowAndArrows = new Composite("Bow and Arrows");

            bowAndArrows.Add(new Leaf("Bow"));
            bowAndArrows.Add(new Leaf("Arrows"));
            root.Add(bowAndArrows);

            foreach (string s in root.Display(0))
            {
                CompositeListBox.Items.Add(s);
            }
        }