コード例 #1
0
ファイル: God.cs プロジェクト: melentyev/spbu-homework
        internal God()
        {
            Func <Gender, Human> makeStudent = (gender) =>
                                               new Student(NamesHelper.RandomName(gender), RandomStudentAge(), gender, NamesHelper.RandomPatronimyc(gender));

            Func <Gender, Human> makeBotan = (gender) =>
                                             new Botan(NamesHelper.RandomName(gender), RandomStudentAge(), gender, NamesHelper.RandomPatronimyc(gender), RandomAvg());

            maleCreators.Add(makeStudent);
            maleCreators.Add(makeBotan);

            maleCreators.Add((gender) =>
                             new Parent(NamesHelper.RandomName(gender), RandomParentAge(), gender, RandomChildren()));

            maleCreators.Add((gender) =>
                             new CoolParent(NamesHelper.RandomName(gender), RandomParentAge(), gender, RandomChildren(), RandomMoney()));

            femaleCreators.Add(makeStudent);
            femaleCreators.Add(makeBotan);
        }
コード例 #2
0
ファイル: God.cs プロジェクト: melentyev/spbu-homework
        private Human CreatePairImpl(Human h)
        {
            if (h is Botan)
            {
                Botan botan = (Botan)h;
                return(new CoolParent(NamesHelper.GenerateParentName(botan),
                                      RandomParentAge(botan),
                                      Gender.Male, RandomChildren(),
                                      (decimal)Math.Pow(RandomMoneyBase, botan.Avg)));
            }
            if (h is Student)
            {
                Student student = (Student)h;
                return(new Parent(NamesHelper.GenerateParentName(student),
                                  RandomParentAge(student),
                                  Gender.Male, RandomChildren()));
            }
            if (h is CoolParent)
            {
                CoolParent coolParent = (CoolParent)h;
                Gender     g          = SelectGender();
                return(new Botan(NamesHelper.RandomName(g),
                                 RandomStudentAge(coolParent), g,
                                 NamesHelper.GeneratePatronimyc(coolParent.Name, g),
                                 Math.Log10((double)coolParent.Money)));
            }

            if (h is Parent)
            {
                Parent parent = (Parent)h;
                Gender g      = SelectGender();
                return(new Student(NamesHelper.RandomName(g),
                                   RandomStudentAge(parent), g,
                                   NamesHelper.GeneratePatronimyc(parent.Name, g)));
            }
            throw new ArgumentException("human");
        }