Esempio n. 1
0
        public static void GetRelationship(String Name, String relationType)
        {
            Person person = FamilyMembers.Find(r => r.Name == Name);

            if (person == null)
            {
                Console.WriteLine("PERSON_NOT_FOUND");
                return;
            }

            switch (relationType)
            {
            case "Siblings":
            case "Sibling":
            {
                List <String> siblings = person.Sibling(null);
                if (siblings == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s siblings are - ");
                    foreach (String name in siblings)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Maternal-Aunt":
            {
                List <String> aunts = person.MaternalAunt();
                if (aunts == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Maternal-aunts are - ");
                    foreach (String name in aunts)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Paternal-Uncle":
            {
                List <String> uncles = person.PaternalUncle();
                if (uncles == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Paternal-Uncle are - ");
                    foreach (String name in uncles)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Maternal-Uncle":
            {
                List <String> uncles = person.MaternalUncle();
                if (uncles == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Maternal-Uncle are - ");
                    foreach (String name in uncles)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Paternal-Aunt":
            {
                List <String> aunts = person.PaternalAunt();
                if (aunts == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Paternal-Aunts are - ");
                    foreach (String name in aunts)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Sister-In-Law":
            {
                Person        spouse = person.Spouse();
                List <String> sil    = new List <String>();
                if (spouse != null)
                {
                    sil = spouse.Sibling("Female");
                }


                List <String> brothers = person.Sibling("Male");
                foreach (String brother in brothers)
                {
                    Person bro  = FamilyMembers.Find(r => r.Name == brother);
                    Person wife = bro.Spouse();
                    sil.Add(wife.Name);
                }


                Console.WriteLine(person.Name + "'s Sister-in-laws are - ");
                foreach (String name in sil)
                {
                    Console.WriteLine(name);
                }

                break;
            }

            case "Brother-In-Law":
            {
                Person        spouse = person.Spouse();
                List <String> bil    = new List <String>();
                if (spouse != null)
                {
                    bil = spouse.Sibling("Male");
                }

                List <String> sisters = person.Sibling("Female");
                foreach (String sister in sisters)
                {
                    Person sis     = FamilyMembers.Find(r => r.Name == sister);
                    Person husband = sis.Spouse();
                    bil.Add(husband.Name);
                }


                Console.WriteLine(person.Name + "'s Brother-in-laws are - ");
                foreach (String name in bil)
                {
                    Console.WriteLine(name);
                }

                break;
            }

            case "Son":
            {
                List <String> sons = person.Children("Male");
                if (sons == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Sons are - ");
                    foreach (String name in sons)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }

            case "Daughter":
            {
                List <String> daughters = person.Children("Female");
                if (daughters == null)
                {
                    Console.WriteLine("NONE");
                }
                else
                {
                    Console.WriteLine(person.Name + "'s Daughters are - ");
                    foreach (String name in daughters)
                    {
                        Console.WriteLine(name);
                    }
                }
                break;
            }
            }

            //Console.ReadLine();
        }