예제 #1
0
        static void Main(string[] args)
        {
            MethodInfo oldestMemberMethod = typeof(Family).GetMethod("GetOldestMember");
            MethodInfo addMemberMethod = typeof(Family).GetMethod("AddMember");
            if (oldestMemberMethod == null || addMemberMethod == null)
            {
                throw new Exception();
            }

            Family family = new Family();

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

                family.Members.Add(new Person(input[0],input[1]));
            }

            Console.WriteLine(family.GetOldestMember());
        }
예제 #2
0
파일: Program.cs 프로젝트: hammer4/SoftUni
        static void Main(string[] args)
        {
            MethodInfo oldestMemberMethod = typeof(Family).GetMethod("GetOldestMember");
            MethodInfo addMemberMethod = typeof(Family).GetMethod("AddMember");
            if (oldestMemberMethod == null || addMemberMethod == null)
            {
                throw new Exception();
            }

            Family family = new Family();
            int count = int.Parse(Console.ReadLine());
            for(int i=0; i<count; i++)
            {
                string[] tokens = Console.ReadLine().Split(' ');
                string name = tokens[0];
                int age = int.Parse(tokens[1]);

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

            Person oldestMember = family.GetOldestMember();
            Console.WriteLine("{0} {1}", oldestMember.name, oldestMember.age);
        }