public List<Person> OldSisters()
{
List<Person> list1 = mother.children.Where(c => c.sex == 'F' && c.age > age);
List<Person> list2 = father.children.Where(c => c.sex == 'F' && c.age > age);
return list1.Union(list2).Distinct();
}
public List<Person> AllAncestors()
{
List<Person> list = new List<Person>();
Add(mother, list);
Add(father, list);
return list;
}
private void Add(Person p, List<Person> list)
{
if (p == null) return;
list.Add(p);
Add(p.mother, list);
Add(p.father, list);
}
{
List<Person> list1 = mother.children.Where(c => c.sex == 'F' && c.age > age);
List<Person> list2 = father.children.Where(c => c.sex == 'F' && c.age > age);
return list1.Union(list2).Distinct();
}
public List<Person> AllAncestors()
{
List<Person> list = new List<Person>();
Add(mother, list);
Add(father, list);
return list;
}
private void Add(Person p, List<Person> list)
{
if (p == null) return;
list.Add(p);
Add(p.mother, list);
Add(p.father, list);
}