Untitled

mail@pastecode.io avatar
unknown
csharp
14 days ago
992 B
0
Indexable
Never
//Program
public static void SetAllChildrenInMonth()
{
    foreach(Month month in months)
    {
        foreach(Child child in children)
        {
            if(child.month == month)
            {
                month.AddChild(child);
            }    
        }
    }
} 
//Month
namespace Checking
{
    public class Month
    {
        public string Name;
        public Child[] Children;
        public Month(string name, Child child)
        {
            Name = name;
            if (Children.Length == 0)
            {
                Children = new Child[1];
                Children[0] = child;
            }
        }
        public Month(string name)
        {
            Name = name;
        }
        public void AddChild(Child child)
        {
            Child[] tempChild = new Child[Children.Length+1];
            Children.CopyTo(tempChild, 1);
            tempChild[0] = child;
            Children = tempChild;
        }
    }
}
Leave a Comment