Beispiel #1
0
        static void Main(string[] args)
        {
            RootChildren rootChildren = new RootChildren(10);

            rootChildren.Childrens.Add(new RootChildren(1));
            rootChildren.Childrens.Add(new RootChildren(2));

            RootChildren rootChildren1 = new RootChildren(8);

            rootChildren1.Childrens.Add(new RootChildren(7));
            rootChildren1.Childrens.Add(new RootChildren(6));

            RootChildren rootChildren2 = new RootChildren(7);

            rootChildren2.Childrens.Add(new RootChildren(3));
            rootChildren2.Childrens.Add(new RootChildren(11));

            rootChildren.EqualsRoots(rootChildren1);

            Console.WriteLine(rootChildren.Root);
            PrintList(rootChildren.Childrens);

            rootChildren.EqualsRoots(rootChildren2);
            Console.WriteLine(rootChildren.Root);
            PrintList(rootChildren.Childrens);

            PrintList(rootChildren.Childrens[2].Childrens);
            PrintList(rootChildren.Childrens[2].Childrens[2].Childrens);
        }
 public void EqualsRoots(RootChildren rootChildren)
 {
     if (this.Root > rootChildren.Root)
     {
         RootChildren rootCh = new RootChildren(this.Root, this.Childrens);
         Root = rootChildren.Root;
         rootChildren.Childrens.Add(rootCh);
         Childrens = rootChildren.Childrens;
     }
 }