Beispiel #1
0
 // TODO: zaimplementuj tę metodę tak, żeby wyświetliła wszystkie osoby w kartotece (tj.
 // w obiekcie 'persons')
 private static void PrintPersonsMenuItem(PersonCollection persons)
 {
     for (int i = 0; i < persons.Count; i++)
     {
         Console.WriteLine(persons.GetAt(i));
     }
 }
Beispiel #2
0
        // TO ZROBIMY NA ZAJĘCIACH
        private static void DeletePersonMenuItem(PersonCollection persons)
        {
            Console.WriteLine("Podaj index osoby ktora chcesz usunac:");
            int index;

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

            if (index >= 0 && index < persons.Count)

            {
                Person person = persons.GetAt(index);
                Console.WriteLine($"Czy na pewno chcesz usunac osobe:{person} (t/n)?");
                if (Console.ReadLine() == "t")
                {
                    persons.Delete(index);

                    Console.WriteLine("Uzytkownik zostal prawidlowo usuniety");
                }
            }

            else

            {
                Console.WriteLine("Nie ma takiego indexu");
            }
        }
        public void SortPersonCollectionByYoungestToOldest()
        {
            PersonCollection testList = new PersonCollection();

              Person MaxG = new Person("Max", "Gehred", new DateTime(2001, 9, 30), "31111111-2222-3333-4444-555555555555");
              Person CharlotteG = new Person("Charlotte", "Gehred", new DateTime(2005, 4, 21), "41111111-2222-3333-4444-555555555555");
              Person MadelineG = new Person("Madeline", "Gehred", new DateTime(1988, 4, 15), "14111111-2222-3333-4444-555555555555");
              Person CecilaG = new Person("Cecila", "Gehred", new DateTime(1990, 6, 21), "15111111-2222-3333-4444-555555555555");
              testList.Add(MaxG);
              testList.Add(CharlotteG);
              testList.Add(MadelineG);
              testList.Add(CecilaG);

              testList.Sort(new PersonComparerByAgeYoungestToOldest());

              Assert.IsTrue((testList.GetAt(3) == MadelineG));
              Assert.IsTrue((testList.GetAt(2) == CecilaG));
              Assert.IsTrue((testList.GetAt(1) == MaxG));
              Assert.IsTrue((testList.GetAt(0) == CharlotteG));
        }
Beispiel #4
0
        // TO ZROBIMY NA ZAJĘCIACH
        private static void EditPersonMenuItem(PersonCollection persons)
        {
            Console.WriteLine("Podaj index osoby, ktora chcesz edytowac :");
            int index;

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

            if (index >= 0 && index < persons.Count)

            {
                Person person = persons.GetAt(index);

                Console.WriteLine(person);
                Console.WriteLine("Podaj nowe imie:");

                person.FirstName = Console.ReadLine();

                Console.WriteLine("Podaj nowe nazwisko:");

                person.LastName = Console.ReadLine();


                Console.WriteLine("Podaj nowy wiek:");

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

                Console.WriteLine("Podaj nowa płeć:");

                person.Sex = Console.ReadLine();

                Console.WriteLine("Podaj nowy wzrost:");

                person.Height = int.Parse(Console.ReadLine());
            }

            else

            {
                Console.WriteLine("Nie ma takiego indexu");
            }
        }