public static List <Ape> GetCousins(ApeFamilyTree familyTree, Ape ape) { List <Ape> result = new List <Ape>(); List <Ape> father = GetFather(familyTree, ape); List <Ape> mother = GetMother(familyTree, ape); List <Ape> fatherSideCousins = new List <Ape>(); foreach (var fatherSideSibling in GetSiblings(familyTree, father.ElementAt(0))) { fatherSideCousins.AddRange(GetChildren(familyTree, fatherSideSibling)); } List <Ape> motherSideCousins = new List <Ape>(); foreach (var motherSideSibling in GetSiblings(familyTree, mother.ElementAt(0))) { motherSideCousins.AddRange(GetChildren(familyTree, motherSideSibling)); } result.AddRange(fatherSideCousins); result.AddRange(motherSideCousins); return(result); }
public static List <Ape> GetFather(ApeFamilyTree familyTree, Ape ape) { ApeFamily family = ape.GetFamily(); return(new List <Ape>() { family?.Partners.SingleOrDefault(e => e != ape && e.Gender == GenderType.Male) }); }
public static List <Ape> GetPaternalUncle(ApeFamilyTree familyTree, Ape ape) { List <Ape> result = new List <Ape>(); Ape father = GetFather(familyTree, ape).ElementAt(0); result.AddRange(GetBrothers(familyTree, father)); result.AddRange(GetBrotherInLaws(familyTree, father)); return(result); }
public static List <Ape> GetMaternalAunt(ApeFamilyTree familyTree, Ape ape) { List <Ape> result = new List <Ape>(); Ape mother = GetMother(familyTree, ape).ElementAt(0); result.AddRange(GetSisters(familyTree, mother)); result.AddRange(GetSisterInLaws(familyTree, mother)); return(result); }
public static List <Ape> GetSons(ApeFamilyTree familyTree, Ape ape) { ApeFamily family = familyTree.GetApeFamilies().SingleOrDefault(p => p.Partners.Contains(ape)); if (family != null) { return(family.Children.Where(c => c.Gender == GenderType.Male).ToList()); } return(new List <Ape>()); }
public static List <Ape> GetChildren(ApeFamilyTree familyTree, Ape ape) { ApeFamily family = familyTree.GetApeFamilies().SingleOrDefault(p => p.Partners.Contains(ape)); if (family != null) { return(family.Children.ToList()); } return(new List <Ape>()); }
public static List <Ape> GetSisters(ApeFamilyTree familyTree, Ape ape) { ApeFamily family = ape.GetFamily(); if (family != null) { return(family.Children.Where(elem => elem != ape && elem.Gender != GenderType.Male).ToList()); } return(new List <Ape>()); }
public static List <Ape> GetSiblings(ApeFamilyTree familyTree, Ape ape) { ApeFamily family = ape.GetFamily(); if (family != null) { return(family.Children.Where(elem => elem != ape).ToList()); } return(new List <Ape>()); }
public static List <Ape> GetBrotherInLaws(ApeFamilyTree familyTree, Ape ape) { List <Ape> result = new List <Ape>(); result.AddRange(GetBrothers(familyTree, ape.GetSpouse())); List <Ape> sisters = GetSisters(familyTree, ape); foreach (var sister in sisters) { result.Add(sister.GetSpouse()); } return(result); }
public static List <Ape> GetGrandDaugthers(ApeFamilyTree familyTree, Ape ape) { ApeFamily family = familyTree.GetApeFamilies().SingleOrDefault(p => p.Partners.Contains(ape)); List <Ape> children = GetChildren(familyTree, ape); List <Ape> grandChildren = new List <Ape>(); foreach (var child in children) { grandChildren.AddRange(GetChildren(familyTree, child).Where(c => c.Gender == GenderType.Female)); } return(grandChildren); }