Пример #1
0
        static void Draw(Component c, string space)
        {
            c.Draw(space);

            if (c.GetChilds() == null)
            {
                return;
            }

            foreach (Component child in c.GetChilds())
            {
                Draw(child, space + "    ");
            }
        }
Пример #2
0
        static Boolean isBinary(Component c)
        {
            if (c.GetChilds() == null)
            {
                return(true);
            }
            Boolean isNodeBinary = c.isBinary();

            foreach (Component child in c.GetChilds())
            {
                isNodeBinary = isNodeBinary && isBinary(child);
            }
            return(isNodeBinary);
        }
Пример #3
0
        static bool IsBinary(Component c)
        {
            if (!c.IsBinary())
            {
                return(false);
            }

            if (c.GetChilds() == null || c.GetChilds().Count == 0)
            {
                return(true);
            }

            return(IsBinary(c.GetChilds()[0]) && IsBinary(c.GetChilds()[1]));
        }
Пример #4
0
        static bool IsBinary(Component c)
        {
            if (!c.IsBinary())
            {
                return(false);
            }

            if (c.GetChilds() == null)
            {
                return(true);
            }

            return(IsBinary(c.GetChilds().Last()) && IsBinary(c.GetChilds().First()));
        }
Пример #5
0
        static Boolean isEvan(Component c)
        {
            if (c.GetChilds() == null)
            {
                return(c.isEvan());
            }
            Boolean isNodeEvan = c.isEvan();

            foreach (Component child in c.GetChilds())
            {
                isNodeEvan = isNodeEvan && isEvan(child);
            }
            return(isNodeEvan);
        }
Пример #6
0
        static bool IsBinary(Component root)
        {
            if (root.GetChilds() == null)
            {
                return(true);
            }
            if (root.GetChilds().Count != 0 && root.GetChilds().Count != 2)
            {
                return(false);
            }
            bool flag = true;

            foreach (Component component in root.GetChilds())
            {
                flag &= IsBinary(component);
            }
            return(flag);
        }
Пример #7
0
 static bool IsBinary(Component biNonde)
 {
     // Check if there is a leaf
     if (biNonde.GetChilds() == null)
     {
         return(true);
     }
     // If we get here it isn't a leaf it is a composite
     // Check if the current composite isn't binary
     else if (!biNonde.IsBinary())
     {
         return(false);
     }
     // Perform the method on every child
     else
     {
         return((biNonde.GetChilds().First().IsBinary()) && biNonde.GetChilds().Last().IsBinary());
     }
 }
Пример #8
0
 static bool IsBinary(Component c)
 {
     if (!c.IsBinary())
     {
         return(false);
     }
     if (c.GetChilds() == null)
     {
         return(true);
     }
     foreach (Component child in c.GetChilds())
     {
         if (!IsBinary(child))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #9
0
        static bool CheckEven(Component obj)
        {
            if (obj.GetNum() % 2 != 0)
            {
                return(false);
            }

            if (obj.GetChilds() == null)//in case a leaf is last
            {
                if (obj.GetNum() % 2 != 0)
                {
                    return(false);
                }
            }

            foreach (Component c in obj.GetChilds())
            {
                return(CheckEven(c));
            }

            return(true);
        }
Пример #10
0
        public static bool IsFull(Component root)
        {
            bool left;
            bool right;
            bool result = true;

            if (root is Composite)
            {
                if (root.GetChilds().Count != 2 && root.GetChilds().Count != 0)
                {
                    result = false;
                }
                else if (root.GetChilds()[0] != null)
                {
                    left  = IsFull(root.GetChilds()[0]);
                    right = IsFull(root.GetChilds()[1]);

                    result = right && left;
                }
            }

            return(result);
        }
Пример #11
0
 static bool isBinary(Component c)
 {
     if (c.GetChilds() != null && c.GetChilds().Count != 2 && c.GetChilds().Count != 0)
     {
         return(false);
     }
     else if (c.GetChilds() == null || c.GetChilds().Count == 0)
     {
         return(true);
     }
     else
     {
         return(isBinary(c.GetChilds()[0]) && isBinary(c.GetChilds()[1]));
     }
 }