Пример #1
0
        public Person MakeBaby(Person other)
        {
            if (other == null && Spouse.Person != null)
                other = Spouse.Person;
            else if (Spouse.Person == null)
            {
                throw new Exception("No-one to make baby with!"); // teehee
            }

            if (other == null)
                throw new Exception("No-one to make baby with!");

            Person mother;
            Person father;
            if (Gender == Gender.Female)
            {
                father = other;
                mother = this;
            }
            else
            {
                father = this;
                mother = other;
            }

            var baby = new Person(mother, father);

            Console.WriteLine("{0} and {1} are the proud new parents of baby {2}!", mother.Name, father.Name, baby.Name);

            Pregnant = false;
            other.Pregnant = false;

            Children.Add(new Relationship { Person = baby, RelationType = Relation.Child });
            baby.Mother = new Relationship
            {
                Person = mother,
                RelationType = Relation.Mother
            };

            baby.Father = new Relationship
            {
                Person = father,
                RelationType = Relation.Father
            };

            baby.AddLifeEvent(new Birth { Year = TimeManager.Year });
            return baby;
        }