Пример #1
0
        public static void menu()
        {
            Student lista = new Student();

            WriteLine("Podaj numer opearacji.\n1. Dodaj studenta recznie \n2. Wczytaj z pliku \n3. Sortuj po imieniu\n4. Sortuj po nazwisku\n5. Sortuj po nr albumu\n6. Sortuj po dacie\n7. Powtórzenia\n8. Czas\n9. Sortowanie całościowe\n0. Zapis do pliku\n Esc. Koniec");
            var key = Console.ReadKey(true);

            while (key.Key != ConsoleKey.Escape)
            {
                if (key.Key == ConsoleKey.D1)
                {
                    lista.addStudent(getStudent());
                }
                else if (key.Key == ConsoleKey.D2)
                {
                    List <Stud> students = fromFile();
                    foreach (Stud stud in students)
                    {
                        lista.addStudent(stud);
                    }
                }
                else if (key.Key == ConsoleKey.D3)
                {
                    lista.sort(1);
                    showStud(lista);
                }
                else if (key.Key == ConsoleKey.D4)
                {
                    lista.sort(2);
                    showStud(lista);
                }
                else if (key.Key == ConsoleKey.D5)
                {
                    lista.sort(3);
                    showStud(lista);
                }
                else if (key.Key == ConsoleKey.D6)
                {
                    lista.sort(4);
                    showStud(lista);
                }
                else if (key.Key == ConsoleKey.D7)
                {
                    List <(string, int)> wynik = lista.Repeats();
                    for (int i = 0; i < wynik.Count; i++)
                    {
                        WriteLine(wynik[i].Item1 + ": " + wynik[i].Item2);
                    }
                }
                else if (key.Key == ConsoleKey.D8)
                {
                    List <(string, int)> wynik = lista.SameData();
                    for (int i = 0; i < wynik.Count; i++)
                    {
                        WriteLine(wynik[i].Item1 + ": " + wynik[i].Item2);
                    }
                }
                else if (key.Key == ConsoleKey.D9)
                {
                    lista.sort2(5);
                    showStud(lista);
                }
                else if (key.Key == ConsoleKey.D0)
                {
                    lista.fileSave();
                }
                else
                {
                }
                WriteLine("Podaj numer opearacji.\n1. Dodaj studenta recznie \n2. Wczytaj z pliku \n3. Sortuj po imieniu\n4. Sortuj po nazwisku\n5. Sortuj po nr albumu\n6. Sortuj po dacie\n 7. Powtórzenia\n8. Czas\n9. Sortowanie całościowe\n0. Zapis do pliku\n Esc. Koniec");

                key = Console.ReadKey(true);
            }
        }