private static IEnumerable<Human> GeneratePairs(IGod god, IReadOnlyList<Human> humans) { var pairs = new Human[humans.Count]; for (var i = 0; i < humans.Count; ++i) { pairs[i] = god.CreatePair(humans[i]); } return pairs; }
public Human CreatePair(Human human) { if (human == null) { throw new ArgumentNullException(Properties.Resources.NullHuman); } Human newHuman; if (human is Botan) { var botan = (Botan) human; var name = Names.NameFromPatronymic(botan.Sex, botan.Patronymic); newHuman = new CoolParent(Randomizer.GetRandomParentAge(botan.Age), name, Sex.Male, Randomizer.GetRandomChildsAmount(1), Money.MarkToMoney(botan.AverageMark)); } else if (human is CoolParent) { var coolParent = (CoolParent) human; var sex = Randomizer.GetRandomSex(); newHuman = new Botan(Randomizer.GetRandomStudentAge(), Names.GenerateName(sex), sex, Names.PatronymicFromParentName(sex, coolParent.Name), Money.MoneyToMark(coolParent.MoneyAmount)); } else if (human is Student) { var student = (Student) human; var name = Names.NameFromPatronymic(student.Sex, student.Patronymic); newHuman = new Parent(Randomizer.GetRandomParentAge(student.Age), name, Sex.Male, Randomizer.GetRandomChildsAmount(1)); } else if (human is Parent) { var parent = (Parent) human; var sex = Randomizer.GetRandomSex(); return new Student(Randomizer.GetRandomStudentAge(), Names.GenerateName(sex), sex, Names.PatronymicFromParentName(sex, parent.Name)); } else { throw new ArgumentException(Properties.Resources.InvalidHumanType); } _humans.Add(newHuman); return newHuman; }