Exemple #1
0
 } // Adam and Eve
 public Human(Human mother, Human father)
 {
     NumberOfPeopleAlive += 1;
     PersonNumber = GeneratePersonNumber(Birthdate);
     Friends = new List<Human>();
     Father = father;
     Mother = mother;
     Children = new List<Human>();
     Parents = new List<Human>();
 }
Exemple #2
0
        public Human MakeBabyWithAnotherAdult(Human partner)
        {
            Human baby = null;
            if (this.Sex != partner.Sex)
            {
                baby = this.Sex == Sex.Female ? new Human(this, partner) : new Human(partner, this);
            }
            //Children.Add(baby);
            //partner.Children.Add(baby);

            return baby;
        }
Exemple #3
0
        public bool MarryAnotherAdult(Human partner)
        {
            if (this.Age > 18 && partner.Age > 18)
            {
                if (CheckIfConsious() && partner.CheckIfConsious())
                {
                    if (Partner == null && partner.Partner == null)
                    {
                        if (this != partner)
                        {
                            if (CheckIfRelatives(partner))
                            {
                                _partner = partner;
                                partner._partner = this;
                                return true;
                            }
                            Console.WriteLine("Too related!!!");
                        }
                        else
                            Console.WriteLine($"{FirstName} can't marry themselves.");
                    }
                    else
                        Console.WriteLine(
                            $"Both parties ({FirstName} and {partner.FirstName}) must not be married no someone else.");
                }
                else
                    Console.WriteLine(
                        $"Both parties ({FirstName} and {partner.FirstName}) must both be consious.");
            }
            else
                Console.WriteLine(
                    $"Both parties ({FirstName} and {partner.FirstName}) must both be over 18.");

            return false;
        }
Exemple #4
0
 protected Human(string firstName, string lastName, Human mother, Human father) : this(mother, father)
 {
     FirstName = firstName;
     LastName = lastName;
 }
Exemple #5
0
 public bool CheckIfFamilyTiesAreOkForMarriage(Human partner)
 {
     if (!(this.Mother == Partner.Mother && this.Father == partner.Father))
     {
         if (!(this.Mother == partner || this.Father == partner))
             return true;
     }
     return false;
 }
Exemple #6
0
        public bool CheckIfRelatives2(Human partner)
        {
            Human mother = Mother;
            Human father = Father;

            while (partner != father)
            {
                if (father.Children.Any(child => partner == child))
                    return false;
                if (father.Father == null)
                    return true;

                father = father.Father;

                while (partner != mother)
                {
                    if (mother.Children.Any(child => partner == child))
                        return false;
                    if (mother.Father == null)
                        return true;

                    mother = mother.Mother;
                }
            }
            return false;
        }