Exemplo n.º 1
0
        public void Add(Family subFamily)
        {
            if (SubFamilies.Any(f => f.AllMembers.Intersect(subFamily.AllMembers).Count() != 0))
            {
                throw new InvalidOperationException($"A member of the sub-family to be added is already a direct member of the family or a member of an existing sub-family.");
            }

            this.SubFamilies.Add(subFamily);
        }
Exemplo n.º 2
0
        public void Add(Person person)
        {
            if (SubFamilies.Any(f => f.AllMembers.Contains(person)))
            {
                throw new InvalidOperationException($"{person} is already a member of a sub-family of this family and cannot be added again.");
            }

            this.DirectMembers.Add(person);
            person.DirectFamily = this;
        }