示例#1
0
        public void OutputSiblings(HashtableEx siblings, string childRelation, Person[] array)
        {
            int h = siblings.values.Count;
            if (h > 0)
            {
                Console.Write("\n-----------------------------\n");

                Console.Write("\n" + childRelation + "\n");
                for (int i = 0; i < h; i++)
                {
                    int i = 0;
                    //object[] ar = new object[0];
                    //ar[i] = Convert.ToInt32(siblings.Get("barn"));
                    foreach (int item in ar)

                        //Console.WriteLine(siblings.Get("barn").ToString());
                        //Console.ReadLine();

                        foreach (Person per in array)
                        {
                            if (item == per.IdPerson)
                            {
                                string gender = per.Gender == true ? "woman" : "man";
                                Console.Write("\n         Id: " + per.IdPerson);
                                Console.Write("\n       Name: " + per.Name + " " + per.LastName);
                                Console.Write("\n     Gender: " + gender);
                                Console.Write("\n     Mother: " + FindName(per.IdMother, array));
                                Console.Write("\n     Father: " + FindName(per.IdFather, array) + "\n");

                            }   //  end of if
                        }   //  end of foreach
                }   //  end of foreach
            }   //  end of if
        }
示例#2
0
 public HashtableEx FindGrandChildren(HashtableEx barnId, Person[] array)
 {
     //int i = 0;
     HashtableEx grandbarnId = new HashtableEx();
     int x = barnId.values.Count;
     //foreach (int item in barnId)
     for (int i = 0; i < x; i++)
     {
         int item = Convert.ToInt16(barnId.Get("barn"));
         foreach (Person per in array)
         {
             if (item != per.IdPerson)
                 if ((item == per.IdMother) || (item == per.IdFather))
                 {   //  IdPerson är pappa eller mamma till
                     //Array.Resize<int>(ref grandbarnId, i + 1);
                     grandbarnId[(int)per.IdPerson] = per.Name;
                     i++;
                 }   //  end of if
         }   //  end of foreach
     }   //  end of foreach
     return grandbarnId;
 }