Esempio n. 1
0
        static void Main()
        {
            // Kreiranje strukture stabla
            CompositeElement root =
                new CompositeElement("Picture");

            root.Add(new PrimitiveElement("Red Line"));
            root.Add(new PrimitiveElement("Blue Circle"));
            root.Add(new PrimitiveElement("Green Box"));

            CompositeElement comp =
                new CompositeElement("Two Circles");

            comp.Add(new PrimitiveElement("Black Circle"));
            comp.Add(new PrimitiveElement("White Circle"));
            root.Add(comp);

            // Dodavanje i brisanje primitivnih elemenata
            PrimitiveElement pe =
                new PrimitiveElement("Yellow Line");

            root.Add(pe);
            root.Remove(pe);

            // Rekurzivni prikaz stabla
            root.Display(1);

            // Čekanje na korisnikov unos
            Console.Read();
        }
Esempio n. 2
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // Create a tree structure
            CompositeElement root =
                new CompositeElement("Picture");

            root.Add(new PrimitiveElement("Red Line"));
            root.Add(new PrimitiveElement("Blue Circle"));
            root.Add(new PrimitiveElement("Green Box"));

            // Create a branch
            CompositeElement comp =
                new CompositeElement("Two Circles");

            comp.Add(new PrimitiveElement("Black Circle"));
            comp.Add(new PrimitiveElement("White Circle"));
            root.Add(comp);

            // Add and remove a PrimitiveElement
            PrimitiveElement pe =
                new PrimitiveElement("Yellow Line");

            root.Add(pe);
            root.Remove(pe);

            // Recursively display nodes
            root.Display(1);

            // Wait for user
            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main()

        {
            // Creo una estructura de arbol

            CompositeElement root = new CompositeElement("Picture");

            root.Add(new PrimitiveElement("Red Line"));

            root.Add(new PrimitiveElement("Blue Circle"));

            root.Add(new PrimitiveElement("Green Box"));

            // Agrego una rama

            CompositeElement comp = new CompositeElement("Two Circles");

            comp.Add(new PrimitiveElement("Black Circle"));

            comp.Add(new PrimitiveElement("White Circle"));

            root.Add(comp);

            // Agrego un elemento primitivo y lo elimino

            PrimitiveElement pe = new PrimitiveElement("Yellow Line");

            root.Add(pe);

            root.Display(1);

            root.Remove(pe);

            // Muestro los nodos recursivamente

            Console.WriteLine("\nDespues de eliminar el nodo primitivo:\n");

            root.Display(1);

            Console.ReadKey();
        }
Esempio n. 4
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // Create a tree structure
            CompositeElement root =
                new CompositeElement("Picture");
            root.Add(new PrimitiveElement("Red Line"));
            root.Add(new PrimitiveElement("Blue Circle"));
            root.Add(new PrimitiveElement("Green Box"));

            // Create a branch
            CompositeElement comp =
                new CompositeElement("Two Circles");
            comp.Add(new PrimitiveElement("Black Circle"));
            comp.Add(new PrimitiveElement("White Circle"));
            root.Add(comp);

            // Add and remove a PrimitiveElement
            PrimitiveElement pe =
                new PrimitiveElement("Yellow Line");
            root.Add(pe);
            root.Remove(pe);

            // Recursively display nodes
            root.Display(1);

            // Wait for user
            Console.ReadKey();
        }