Exemple #1
0
        static void Main(string[] args)
        {
            var family = new Family();

            var count = int.Parse(Console.ReadLine());

            for (var i = 0; i < count; i++)
            {
                var personInfo = Console.ReadLine().Split();
                var name       = personInfo[0];
                var age        = int.Parse(personInfo[1]);

                var person = new Person(name, age);

                family.AddMember(person);
            }

            //Console.WriteLine($"{family.GetOldestMember().Name} {family.GetOldestMember().Age}");

            var peopleMoreThan30 = family.GetOlderThan30();

            foreach (var person in peopleMoreThan30)
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
        public static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            Family family = new Family();

            for (int i = 0; i < num; i++)
            {
                string[] dataInput  = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string   currName   = dataInput[0];
                int      currAge    = int.Parse(dataInput[1]);
                Person   currPerson = new Person(currName, currAge);

                family.AddMember(currPerson);
            }

            Person olderMember = family.GetOldestMember();
            var    olders      = family.GetOlderThan30().ToList().OrderBy(x => x.Name);

            if (olders.Count() > 0)
            {
                foreach (var item in olders)
                {
                    Console.WriteLine($"{item.Name} - {item.Age}");
                }
            }
            //   Console.WriteLine($"{olderMember.Name} {olderMember.Age}");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Family family = new Family();
            int    n      = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split();
                string   name  = input[0];
                int      age   = int.Parse(input[1]);

                Person person = new Person(name, age);

                family.AddMember(person);
            }

            foreach (var member in family.GetOlderThan30())
            {
                Console.WriteLine($"{member.Name} - {member.Age}");
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Family family = new Family();

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split();
                string   name  = input[0];
                int      age   = int.Parse(input[1]);

                family.AddMember(new Person(name, age));
            }

            List <Person> olderThan30 = family.GetOlderThan30(family);

            foreach (var person in olderThan30.OrderBy(x => x.Name))
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }