示例#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]));
     }
 }