Example #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 ();
        }
Example #2
0
 public static void sortFaculties()
 {
     Faculty temp = new Faculty ();
     if (faculties.objectCount < 2)
         return;
     for (int j = 0; j<faculties.getSize()/2 ; j++)
         for (int i = 0; i<faculties.getSize()-1; i++) {
         if (faculties.getElement (i) > faculties.getElement (i + 1)) {
             temp = faculties.getElement (i);
             faculties.pushElement (i, faculties.getElement (i+1));
             faculties.pushElement (i + 1, temp);
         }
     }
 }
Example #3
0
 public static void newFaculty()
 {
     String name = Console.ReadLine ();
     Faculty faculty = new Faculty (name);
     faculties.addObject (faculty);
 }
Example #4
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;
            }
        }
Example #5
0
 //delete faculty
 private void Button_Click_3(object sender, RoutedEventArgs e)
 {
     if (listbox.SelectedIndex != -1)
     {
         Window3 win3 = new Window3();
         win3.Karl.Text += " " + faclist.getElement(listbox.SelectedIndex).name + "?";
         win3.ShowDialog();
         if (win3.flag)
         {
             MyList<Faculty> clear = new MyList<Faculty>();
             Faculty f = new Faculty();
             faclist.Remove(listbox.SelectedIndex);
             foreach (Faculty ff in faclist)
                 clear.addObject(ff);
             listbox.ItemsSource = clear;
         }
     }
 }
Example #6
0
 //add faculti
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     Window1 win1 = new Window1();
     win1.Title = "add new faculty";
     win1.ShowDialog();
     Faculty faculty = new Faculty();
     faculty.name = win1.textbox.Text;
     faclist.addObject(faculty);
     MyList<Faculty> clear = new MyList<Faculty>();
     foreach (Faculty ff in faclist)
         clear.addObject(ff);
     listbox.ItemsSource = clear;
 }