Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var people = new Family();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split().ToArray();

                var name = input[0];
                var age  = int.Parse(input[1]);

                var person = new Person(age, name);
                people.AddMember(person);
            }

            var output = people.MoreThenThirty();

            for (int i = 0; i < output.Count; i++)
            {
                Console.WriteLine($"{output[i].Name} - {output[i].Age}");
            }
        }
    public static void Main()
    {
        MethodInfo oldestMemberMethod = typeof(Family).GetMethod("GetOldestMember");
        MethodInfo addMemberMethod    = typeof(Family).GetMethod("AddMember");

        if (oldestMemberMethod == null || addMemberMethod == null)
        {
            throw new Exception();
        }

        int n      = int.Parse(Console.ReadLine());
        var 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));
        }

        Console.WriteLine(family.GetOldestMember());
    }
        static void Main(string[] args)
        {
            Console.WriteLine("How many family members you will add");
            int n = int.Parse(Console.ReadLine());

            Family family = new Family();
            Person person = new Person();

            for (int i = 0; i < n; i++)
            {
                string[] members = Console.ReadLine().Split(' ');
                family.AddMember
                (
                    person = new Person()
                {
                    Name = members[0],
                    Age  = int.Parse(members[1])
                }
                );
            }
            var oldest = family.GetOldestMember();

            Console.WriteLine(oldest);
        }
Ejemplo n.º 4
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();
        }

        int    num = int.Parse(Console.ReadLine());
        Family fam = new Family();

        for (int i = 0; i < num; i++)
        {
            string[] input  = Console.ReadLine().Split(' ');
            string   name   = input[0];
            int      age    = int.Parse(input[1]);
            Person   member = new Person(name, age);
            fam.AddMember(member);
        }
        Console.Write(fam.GetOldestMember().Name + " ");
        Console.WriteLine(fam.GetOldestMember().Age);
    }
Ejemplo n.º 5
0
    public static void Main()
    {
        MethodInfo oldestMemberMethod = typeof(Family).GetMethod("GetOldestMember");
        MethodInfo addMemberMethod    = typeof(Family).GetMethod("AddMember");

        if (oldestMemberMethod == null || addMemberMethod == null)
        {
            throw new Exception();
        }
        Family family = new Family();
        var    n      = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            var inpArgs = Console.ReadLine().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            var name    = inpArgs[0];
            var age     = int.Parse(inpArgs[1]);
            var person  = new Person(name, age);

            family.AddMember(person);
        }

        family.GetOldestMember();
    }
        static void Main(string[] args)
        {
            int    n             = int.Parse(Console.ReadLine());
            Family currentFamily = new Family();

            for (int i = 0; i < n; i++)
            {
                string[] input     = Console.ReadLine().Split(' ');
                string   name      = input[0];
                int      age       = int.Parse(input[1]);
                Person   newMember = new Person();
                try
                {
                    newMember.Age  = age;
                    newMember.Name = name;
                    currentFamily.AddMember(newMember);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);;
                }
            }
            currentFamily.GetOldestMember();
        }
Ejemplo n.º 7
0
    static void Main()
    {
        MethodInfo oldestMemberMethod = typeof(Family).GetMethod("GetOldestMember");
        MethodInfo addMemberMethod    = typeof(Family).GetMethod("AddMember");

        if (oldestMemberMethod == null || addMemberMethod == null)
        {
            throw new Exception();
        }
        int n      = int.Parse(Console.ReadLine());
        var family = new Family();
        var people = new List <Person>();

        for (int i = 0; i < n; i++)
        {
            var row    = Console.ReadLine().Split(' ');
            var person = new Person(row[0], int.Parse(row[1]));
            family.AddMember(person);
            people.Add(person);
        }
        var oldest = family.GetOldestMember();

        Console.WriteLine(oldest.name + " " + oldest.age);
    }
Ejemplo n.º 8
0
    static void Main()
    {
        MethodInfo oldestMemberMethod = typeof(Family).GetMethod("GetOldestMember");
        MethodInfo addMemberMethod    = typeof(Family).GetMethod("AddMember");

        if (oldestMemberMethod == null || addMemberMethod == null)
        {
            throw new Exception();
        }
        var n      = int.Parse(Console.ReadLine());
        var member = new Person();
        var family = new Family();

        for (int i = 0; i < n; i++)
        {
            var input = Console.ReadLine().Split();
            var name  = input[0];
            var age   = int.Parse(input[1]);
            member.Name = name;
            member.Age  = age;
            family.AddMember(member);
        }
        Console.WriteLine($"{family.GetOldestMember().Name} {family.GetOldestMember().Age}");
    }
Ejemplo n.º 9
0
    static void Main(string[] args)
    {
        var family = new Family();

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            var splitInput = Console.ReadLine().Split();

            var name = splitInput[0];
            var age  = int.Parse(splitInput[1]);

            var person = new Person(name, age);

            family.AddMember(person);
        }
        var olderPerson = family.GetOldestMember();

        if (olderPerson != null)
        {
            Console.WriteLine($"{olderPerson.Name} {olderPerson.Age}");
        }
    }
Ejemplo n.º 10
0
    public static void Main()
    {
        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    iterations = Convert.ToInt32(Console.ReadLine());

        for (int count = 0; count < iterations; count++)
        {
            string[] input         = Console.ReadLine().Split();
            string   personName    = input[0];
            int      personAge     = Convert.ToInt32(input[1]);
            Person   currentMember = new Person(personName, personAge);
            family.AddMember(currentMember);
        }

        Console.WriteLine(family.GetOldestMember().ToString());
    }
Ejemplo n.º 11
0
    public static void Main()
    {
        MethodInfo oldestMemberMethod = typeof(Family).GetMethod("GetOldestMember");
        MethodInfo addMemberMethod    = typeof(Family).GetMethod("AddMember");

        if (oldestMemberMethod == null || addMemberMethod == null)
        {
            throw new Exception();
        }

        var n      = int.Parse(Console.ReadLine());
        var family = new Family();

        for (int i = 0; i < n; i++)
        {
            var tokens = Console.ReadLine().Split().ToArray();
            var person = new Person(tokens[0], int.Parse(tokens[1]));
            family.AddMember(person);
        }

        var oldestMember = family.GetOldestMember();

        Console.WriteLine($"{oldestMember.Name} {oldestMember.Age}");
    }