Exemple #1
0
        /// <summary>
        /// Возвращает случайные данные взрослого определенного пола
        /// </summary>
        /// <param name="gender">Пол взрослого</param>
        /// <returns>Данные врослого</returns>
        public static PersonBase GetRandomAdult(Gender gender)
        {
            int randAge = _random.Next(19, 122);

            var adult = new Adult();

            GetBaseInfo(adult, gender, randAge);

            adult.StateOfMarriage = TextReader("Marriage.txt");
            adult.NameOfJob       = TextReader("NameOfJob.txt");
            return(adult);
        }
        static void Main()
        {
            List<Person> listOfPeople = new List<Person>();

            Adult Joe = new Adult("Joe", "Male");
            Adult Sarah = new Adult("Sarah", "Female");
            Child Natalia = new Child("Natalia", "Female");
            Child Bobby = new Child("Bobby", "Male");

            listOfPeople.Add(Joe);
            listOfPeople.Add(Sarah);
            listOfPeople.Add(Natalia);
            listOfPeople.Add(Bobby);

            Joe.AddChild(new Child("Tommy", "Male"));
            Sarah.AddChild(new Child("Kristin", "Female"));
            Sarah.AddChild(new Child("Jessica", "Female"));

            Natalia.AddToy(new Toy(Color.Cyan, new Size(100, 50)));
            Natalia.AddToy(new Toy(Color.Red, new Size(40, 90)));
            Natalia.AddToy(new Toy(Color.Gold, new Size(45, 65)));
            Bobby.AddToy(new Toy(Color.GreenYellow, new Size(120, 200)));

            Joe.IsBoring = true;
            Sarah.IsBoring = false;

            foreach (var person in listOfPeople)
            {
                if (person is Child)
                {
                    Child child = (Child)person;
                    Console.WriteLine(child.ToString());
                    child.Play();
                }
                else if (person is Adult)
                {
                    Adult adult = (Adult)person;
                    Console.WriteLine(adult.ToString());
                    adult.Work();
                    Console.WriteLine("Is {0} boring? -> {1}", adult.name, true == adult.IsBoring ? "Yes" : "No");
                }
                else
                    throw new ArgumentException("ERROR: Invalid person!");

                Console.WriteLine();
            }
        }
Exemple #3
0
        /// <summary>
        /// Формирует персону типа "Взрослый"
        /// </summary>
        /// <returns>возвращает персону класса Adult</returns>
        public static Adult GetPerson(Gender gender, Marriage maritalStatus)
        {
            Adult newAdult = new Adult();

            string[] nameBaseMan =
            {
                "Сергей",  "Иван",   "Алексей",
                "Михаил",  "Андрей", "Федот",
                "Аркадий", "Натан",  "Мстислав",
                "Олег",    "Епифан", "Абрам",
            };
            string[] nameBaseWoman =
            {
                "Сара",    "Марина",  "Алена",
                "Надежда", "Анна",    "Фаина",
                "Алиса",   "Наталья", "Екатерина",
                "Ольга",   "Елена",   "Юлия",
            };
            string[] surnameBaseMan =
            { "Волков",  "Сумароков", "Гвоздев",
              "Шилов",   "Капустин",  "Петров",
              "Флажков", "Газманов" };
            string[] surnameBaseWoman =
            {
                "Волкова",  "Сумарокова", "Гвоздева",
                "Шилова",   "Капустина",  "Петрова",
                "Флажкова", "Газманова"
            };
            string[] jobBase =
            {
                "Безработн(-ый/-ая)", "Школа №8",      "Областная клиническая больница",
                "АО СО ЕЭС",          "ИП Пирогова",
                "ФГУП 'ПО'Заря'",     "Автодор Томск",
                "Продуктовый магазин 'Близкий'"
            };

            (string, string)nameSurname = ("", "");
            switch (gender)
            {
            case Gender.Female:
            {
                nameSurname = CreatingName.GetNameSurname(nameBaseWoman, surnameBaseWoman);
                break;
            }

            case Gender.Male:
            {
                nameSurname = CreatingName.GetNameSurname(nameBaseMan, surnameBaseMan);
                break;
            }
            }
            //TODO: RSDN
            Random random = new Random();

            newAdult.Name    = nameSurname.Item1;
            newAdult.Surname = nameSurname.Item2;
            newAdult.Sex     = gender;
            newAdult.Age     = random.Next(MinAge, MaxAge);
            Thread.Sleep(20);
            newAdult.Passport = $"{random.Next(1000, 10000)} " +
                                $"{random.Next(100000, 1000000)}";
            Thread.Sleep(20);
            newAdult.Job = jobBase[random.Next(0, jobBase.Length)];
            Thread.Sleep(20);
            newAdult.Marriage = maritalStatus;

            return(newAdult);
        }