public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Family family = new Family();

            for (int i = 0; i < n; i++)
            {
                string[] membersData = Console.ReadLine().Split();

                string memberName = membersData[0];
                int    memberAge  = int.Parse(membersData[1]);

                Person member = new Person(memberName, memberAge);

                family.AddMember(member);
            }

            var membersOver30 = family.GetMembersOver30();

            foreach (var person in membersOver30.OrderBy(x => x.Name))
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
Beispiel #2
0
        public static void Main()
        {
            int    rows   = int.Parse(Console.ReadLine());
            Family family = new Family();

            for (int i = 0; i < rows; i++)
            {
                string[] data   = Console.ReadLine().Split().ToArray();
                string   name   = data[0];
                int      age    = int.Parse(data[1]);
                Person   member = new Person(name, age);
                family.AddMember(member);
            }

            List <Person> oldestMember = family.GetMembersOver30();

            foreach (var item in oldestMember)
            {
                Console.WriteLine($"{item.Name} - {item.Age}");
            }
        }