Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Family family = new Family();

            for (int i = 0; i < n; i++)
            {
                string[] personArgs = Console.ReadLine()
                                      .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                                      .ToArray();

                string name = personArgs[0];

                int age = int.Parse(personArgs[1]);

                Person person = new Person(age, name);

                family.AddMember(person);
            }

            Console.WriteLine(family.GetOldestMember());
        }
Exemplo n.º 2
0
        public 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();

                Person person = new Person(input[0], int.Parse(input[1]));
                family.AddMember(person);
            }
            Person[] people = family.GetPeople();
            foreach (var item in people)
            {
                Console.WriteLine($"{item.Name} - {item.Age}");
            }



            //Person person = new Person();
            //Person person1 = new Person(12);
            //Person person2 = new Person("pesho", 21);



            //Person person = new Person("Pesho", 20);
            //Console.WriteLine($"{person.Name} {person.Age}");
            //Person person1 = new Person();
            //person1.Name = "Gosho";
            //person1.Age = 18;
            //Console.WriteLine($"{person1.Name} {person1.Age}");
            //Person person2 = new Person();
            //person2.Name = "Stamat";
            //person2.Age = 43;
            //Console.WriteLine($"{person2.Name} {person2.Age}");
        }
        static void Main(string[] args)
        {
            ////T01
            //Person pesho = new Person()
            //{
            //    Name = "Pesho",
            //    Age = 20
            //};


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

            //Console.WriteLine("---------------------------------------------");

            ////T02
            //var noName = new Person();
            //Console.WriteLine($"NoNameGuy: {noName.Name} {noName.Age}");
            //var gosho = new Person(24);
            //Console.WriteLine($"GoshoYear: {gosho.Name} {gosho.Age}");
            //var stamat = new Person("Stamat", 27);
            //Console.WriteLine($"Stamat: {stamat.Name} {stamat.Age}");

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

            for (int i = 0; i < n; i++)
            {
                var    cmdArgs = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string name    = cmdArgs[0];
                int    age     = int.Parse(cmdArgs[1]);

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

            Console.WriteLine(family.GetOldestMember());
        }
Exemplo n.º 4
0
        public static void Main()
        {
            int peopleCount = int.Parse(Console.ReadLine());

            var family = new Family();

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

                string name = personInfo[0];
                int    age  = int.Parse(personInfo[1]);

                var person = new Person(name, age);

                family.AddMember(person);
            }

            var oldestMan = family.GetOldestMember();

            Console.WriteLine($"{oldestMan.Name} {oldestMan.Age}");
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            //Person pesho = new Person("Pesho", 20);
            //Console.WriteLine($"{pesho.Name} {pesho.Age}");

            //Person gosho = new Person("Gosho", 18);
            //Console.WriteLine($"{gosho.Name} {gosho.Age}");

            //Person stamat = new Person("Stamat", 43);
            //Console.WriteLine($"{stamat.Name} {stamat.Age}");

            //Person person1 = new Person();
            //Person person2 = new Person(12);
            //Person person3 = new Person("Stoyan", 24);

            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]);

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

            //Person oldestPerson = family.GetOldestMember();
            Person[] people = family.GetPeople();
            foreach (var person in people)
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            int    n      = int.Parse(Console.ReadLine());
            Family family = new Family();

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

                string personName = info[0];
                int    personAge  = int.Parse(info[1]);

                Person person = new Person(personName, personAge);
                family.AddMember(person);
            }

            //Person oldestPerson = family.GetOldestMember();
            //Console.WriteLine(oldestPerson);


            List <Person> peopleOverThirty = family.GetPeopleOverThirty().OrderBy(x => x.Name).ToList();

            Console.WriteLine(string.Join(Environment.NewLine, peopleOverThirty));
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            int    countOfLines = int.Parse(Console.ReadLine());
            Family fam          = new Family();

            for (int i = 0; i < countOfLines; i++)
            {
                string[] line = Console.ReadLine()
                                .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                .ToArray();
                string name    = line[0];
                int    age     = int.Parse(line[1]);
                Person current = new Person(name, age);

                fam.AddMember(current);
            }

            Dictionary <string, int> results = fam.GetUnder30();

            foreach (var result in results.OrderBy(x => x.Key))
            {
                Console.WriteLine($"{result.Key} - {result.Value}");
            }
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            int n      = int.Parse(Console.ReadLine());
            var family = new Family();

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

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

                var member = new Person(name, age);

                family.AddMember(member);
            }

            foreach (var name in family.Sort(family.People))
            {
                Console.WriteLine(name.ToString());
            }
        }
        public static void Main()
        {
            Family family = new Family();

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

            for (int i = 0; i < count; i++)
            {
                string[] personInfo = Console.ReadLine()
                                      .Split(" ")
                                      .ToArray();

                string name = personInfo[0];
                int    age  = int.Parse(personInfo[1]);

                Person person = new Person(name, age);

                family.AddMember(person);
            }

            var oldetsMember = family.GetOldersMember();

            Console.WriteLine($"{oldetsMember.Name} {oldetsMember.Age}");
        }
Exemplo n.º 10
0
        public static void Main()
        {
            Family family = new Family();

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

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine()
                                 .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                                 .ToArray();

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

                Person member = new Person(name, age);

                family.AddMember(member);
            }

            var oldestPerson = family.GetOldestMember();

            Console.WriteLine($"{oldestPerson.Name} {oldestPerson.Age}");
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var family = new Family();

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

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

                var person = new Person(name, age);

                family.AddMember(person);
            }

            var peopleMoreThan30 = family.GetMoreThen30();

            foreach (var person in peopleMoreThan30)
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
Exemplo n.º 12
0
        public static void Main()
        {
            int    membersCount = int.Parse(Console.ReadLine());
            Family members      = new Family();

            for (int i = 0; i < membersCount; i++)
            {
                string[] input = Console.ReadLine()
                                 .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                string name   = input[0];
                int    age    = int.Parse(input[1]);
                Person person = new Person(name, age);

                members.AddMember(person);
            }

            List <Person> personThanMore30Year = members.GetMemberMoreThan30();

            foreach (var person in personThanMore30Year)
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            int    n      = int.Parse(Console.ReadLine());
            Family family = new Family();

            for (int i = 0; i < n; i++)
            {
                string[] info = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
                string   name = info[0];
                int      age  = int.Parse(info[1]);

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

            Person oldest = family.GetOldestMember();

            Console.WriteLine(oldest.ToString());

            foreach (var per in family.People.Where(x => x.Age > 30).OrderBy(x => x.Name))
            {
                Console.WriteLine(per.ToString());
            }
        }
        static void Main(string[] args)
        {
            var    n      = int.Parse(Console.ReadLine());
            Family 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]);
                if (age > 30)
                {
                    Person person = new Person(name, age);
                    family.AddMember(person);
                }
            }

            foreach (var person in family.People.OrderBy(x => x.Name))
            {
                var name = person.Name;
                var age  = person.Age;
                Console.WriteLine($"{name} - {age}");
            }
        }
Exemplo n.º 15
0
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Family fam = 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 pr = new Person(name, age);

                fam.AddMember(pr);
            }
            List <Person> person = fam.GetOldestMember();

            foreach (var item in person)
            {
                Console.WriteLine($"{item.Name} - {item.Age}");
            }
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            int    countPeople = int.Parse(Console.ReadLine());
            Family family      = new Family();

            for (int i = 0; i < countPeople; i++)
            {
                string[] line = Console.ReadLine()
                                .Split();
                string name = line[0];
                int    age  = int.Parse(line[1]);
                if (age > 30)
                {
                    Person currentPerson = new Person(name, age);
                    family.AddMember(currentPerson);
                }
            }
            List <Person> sortedFamily = family.sortPeople();

            foreach (Person currentPerson in sortedFamily)
            {
                Console.WriteLine($"{currentPerson.Name} - {currentPerson.Age}");
            }
        }
        static void Main(string[] args)
        {
            int    n      = int.Parse(Console.ReadLine());
            Family family = new Family();

            family.People = new System.Collections.Generic.List <Person>();

            for (int i = 0; i < n; i++)
            {
                string[] personParams = Console.ReadLine()
                                        .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                string name = personParams[0];
                int    age  = int.Parse(personParams[1]);

                Person person = new Person(name, age);

                family.AddMember(person);
            }

            Person oldestMember = family.GetOldestMember();

            Console.WriteLine($"{oldestMember.Name} {oldestMember.Age}");
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var familyMember = new Family();

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

                Person person = new Person(name, age);

                familyMember.AddMember(person);
            }

            foreach (var item in familyMember.FilteredFamily())
            {
                Console.WriteLine($"{item.Name} - {item.Age}");
            }
        }
Exemplo n.º 19
0
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Family family = new Family();

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

                Person person = new Person(name, age);

                family.AddMember(person);
            }

            Person[] oldestPerson = family.GetPeople();

            foreach (var person in oldestPerson)
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            int    numberOfPeople = int.Parse(Console.ReadLine());
            Family family         = new Family();

            for (int i = 0; i < numberOfPeople; i++)
            {
                string[] tokens = Console.ReadLine()
                                  .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                string name = tokens[0];
                int    age  = int.Parse(tokens[1]);

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

            var filteredMembers = family.GetFilteredMembers();

            foreach (var member in filteredMembers)
            {
                Console.WriteLine($"{member.Name} - {member.Age}");
            }
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            int numberOfPeople = int.Parse(Console.ReadLine());

            Family family = new Family();

            for (int i = 0; i < numberOfPeople; i++)
            {
                string[] personAndAge = Console.ReadLine()
                                        .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                string person = personAndAge[0];
                int    age    = int.Parse(personAndAge[1]);

                Person currentPerson = new Person(person, age);
                family.AddMember(currentPerson);
            }
            List <Person> peopleAbove30 = family.AgeOver30();

            foreach (var person in peopleAbove30.OrderBy(x => x.Name))
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());

            Family family = new Family();

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

                string name = personArgs[0];
                int    age  = int.Parse(personArgs[1]);

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

            List <Person> peopleOverThirty = family
                                             .GetPeopleOverThirty()
                                             .OrderBy(x => x.Name)
                                             .ToList();

            Console.WriteLine(string.Join(Environment.NewLine, peopleOverThirty));
        }
        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(' ').ToArray();
                string   name  = input[0];
                int      age   = int.Parse(input[1]);

                Person person = new Person(name, age);

                family.AddMember(person);
            }

            Person[] people = family.GetPeople();

            foreach (var person in people)
            {
                Console.WriteLine($"{person.Name} - {person.Age}");
            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            //var person = new Person();

            //person.Name = Console.ReadLine();
            //person.Age = int.Parse(Console.ReadLine());

            //Console.WriteLine($"{person.Name} \n{person.Age}");
            //string name = Console.ReadLine();
            //int age = int.Parse(Console.ReadLine());
            //var personCtor = new Person(age);
            //var personCtorName = new Person(name, age);
            //Console.WriteLine(personCtor.Name);
            //Console.WriteLine(personCtor.Age);
            //Console.WriteLine(personCtorName.Name);
            //Console.WriteLine(personCtorName.Age);

            //FamilyMembers + OldestMember
            var family       = new Family();
            int membersCount = int.Parse(Console.ReadLine());

            for (int i = 0; i < membersCount; i++)
            {
                string[] currentMember = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                string name = currentMember[0];
                int    age  = int.Parse(currentMember[1]);

                family.AddMember(name, age);
            }
            foreach (var item in family.GetElder())
            {
                Console.WriteLine(string.Join(" - ", item.Key, item.Value));
            }
            ///// dateModifier
            //string startDate = Console.ReadLine();
            //string endDate = Console.ReadLine();

            //var daysDifference = new DateModifier();

            //Console.WriteLine(Math.Abs(daysDifference.GetDateDifference(startDate, endDate)));
            //int carsCount = int.Parse(Console.ReadLine());
            //List<Car> cars = new List<Car>();
            //for (int i = 0; i < carsCount; i++)
            //{
            //    Car car = new Car();
            //    string carEntry = Console.ReadLine();
            //    car.Model = carEntry.Split()[0];
            //    car.FuelAmount = double.Parse(carEntry.Split()[1]);
            //    car.FuelConsumptionPerKilometer = double.Parse(carEntry.Split()[2]);
            //    car.Travelleddistance = 0;

            //    cars.Add(new Car(car.Model, car.FuelAmount, car.FuelConsumptionPerKilometer, car.Travelleddistance));

            //}
            //while (true)
            //{
            //    string[] input = Console.ReadLine().Split();
            //    if (input[0].ToLower() == "end")
            //    {
            //        break;
            //    }

            //    string carModel = input[1];
            //    double distance = double.Parse(input[2]);

            //    Car car = cars.Find(c => c.Model == carModel);
            //    car.Drive(distance);

            //}
            //foreach (var car in cars)
            //{
            //    Console.WriteLine(car);
            //}
        }