Beispiel #1
0
        public static void loadFromFile(String filename)
        {
            FileStream fin;
            try{
                fin = new FileStream(filename,FileMode.Open);
            }catch(FileNotFoundException exc){
                Console.WriteLine (exc.Message + " не удалось открыть файл ");
                return;
            }
            StreamReader reader = new StreamReader (fin);
            String str;
            String[] arr;

            while ((str = reader.ReadLine())!=null) {
                arr = str.Split (' ');
                Faculty temp = new Faculty ();
                temp.name = arr [0];
                int countOfGroup = Convert.ToInt32(arr [1]);

                for (int i = 0; i < countOfGroup; i++) {
                    str = reader.ReadLine ();
                    arr = str.Split (' ');
                    Group tempg = new Group ();
                    tempg.number = int.Parse (arr [0]);
                    int studentsSize = int.Parse (arr [1]);
                    for (int j = 0; j < studentsSize; j++) {
                        str = reader.ReadLine ();
                        arr = str.Split (' ');
                        Student temps = new Student ();
                        temps.name = arr [1];
                        temps.surname = arr [0];
                        tempg.addStudent (temps);
                    }
                    temp.addGroup (tempg);
                }

                faculties.addObject (temp);
            }

            reader.Close ();
            fin.Close ();
        }
Beispiel #2
0
        public static void menuOfFaculty(Faculty fac, int index)
        {
            Console.WriteLine (" 1. Список групп \n 2. Список групп со студентами  \n 3. Добавить группу \n 4. Добавить студента  \n\n\n 5. назад");
            int choice = Convert.ToInt32 (Console.ReadLine ());

            switch (choice) {

            case 1:
                faculties.getElement (index).toStringAllGroup ();
                Console.ReadKey ();
                break;

            case 2:
                faculties.getElement (index).toStringAllGroupsAndStudents ();
                Console.ReadKey ();
                break;

            case 3:
                fac.addGroup ();
                fac.toString ();
                Console.WriteLine (fac.groups.getSize().ToString ());
                getFacultiesList ();
                break;

            case 4:
                break;

            default:
                break;
            }
        }