Пример #1
0
        private static void FindElemInCollection(SortedDictionary <int, PersonAbstract> sortedList)
        {
            Console.WriteLine("По какому параметру хотите искать?\n" +
                              "1) Имя\n" +
                              "2) Возраст\n" +
                              "3) Пол");

            InputInt32("Введите номер выбранного пункта:", out int ind, num => num > 0 && num < 4);

            var foundPerson = new PersonAbstract("", 0, "");

            switch (ind)
            {
            case 1:
                foundPerson = FindElemByName(sortedList);
                break;

            case 2:
                foundPerson = FindElemByAge(sortedList);
                break;

            case 3:
                foundPerson = FindElemByGender(sortedList);
                break;

            default:
                throw new Exception("Ошибка в выборе пункта.");
            }

            if (foundPerson == null)
            {
                Console.WriteLine("Элемент не найден!");
            }
            else
            {
                Console.WriteLine("Найденный элемент: " + foundPerson.ToString());
            }
        }
Пример #2
0
 public StudentFromAbstract(string name, int age, string gender, int course, double averageGrades) : base(name, age, gender)
 {
     BasePerson    = new PersonAbstract(Name, Age, Gender);
     Course        = course;
     AverageGrades = averageGrades;
 }