Beispiel #1
0
        public static void SetComposition(List <Schoolboy> list, List_Assessment[] LA)
        {
            /* Console.WriteLine("Введите имя");
             * string name = Console.ReadLine();
             * Console.WriteLine("Введите отчество");
             * string patronomic = Console.ReadLine();
             * Console.WriteLine("Введите фамилию");
             * string surname = Console.ReadLine();
             * Console.WriteLine("Введите год обучения");
             * int year_of_study;
             * int.TryParse(Console.ReadLine(), out year_of_study);
             * Console.WriteLine("Введите класс");
             * int the_class;
             * int.TryParse(Console.ReadLine(), out the_class);
             * Console.ReadLine();
             *
             * Console.WriteLine("Введите оценки по предметам");
             * Assessment[] As = LA[the_class - 1].LAssessment.ToArray();
             * for(int i = 0; i<As.Length; i++)
             * {
             *   Console.WriteLine("Введите оценку по "+As[i].subject);
             *   int.TryParse(Console.ReadLine(), out int tm);
             *   As[i].assessment = tm;
             * }*/
            Schoolboy tmp = new Schoolboy();

            tmp = ReadSchoolboy(LA);
            list.Add(tmp);
        }
Beispiel #2
0
        public static Schoolboy ReadSchoolboy(List_Assessment[] LA)
        {
            Console.WriteLine("Введите имя");
            string name = Console.ReadLine();

            Console.WriteLine("Введите отчество");
            string patronomic = Console.ReadLine();

            Console.WriteLine("Введите фамилию");
            string surname = Console.ReadLine();

            Console.WriteLine("Введите год обучения");
            int year_of_study = Chek(1980, 2020);

            Console.WriteLine("Введите класс");
            int the_class = Chek(1, 11);

            Console.ReadLine();

            Console.WriteLine("Введите оценки по предметам");
            Assessment[] As = LA[the_class - 1].LAssessment.ToArray();
            for (int i = 0; i < As.Length; i++)
            {
                Console.WriteLine("Введите оценку по " + As[i].subject);
                As[i].assessment = Chek(1, 5);
            }
            Schoolboy Boy = new Schoolboy(name, patronomic, surname, year_of_study, the_class, As);

            return(Boy);
        }
Beispiel #3
0
 public List <Schoolboy> LoadFromFile(string fileName)
 {
     if (File.Exists(fileName))
     {
         using (StreamReader sr = new StreamReader(fileName, System.Text.Encoding.Default))
         {
             List <Schoolboy> list = new List <Schoolboy>();
             while (sr.Peek() > -1)
             {
                 string name       = sr.ReadLine();
                 string Patronymic = sr.ReadLine();
                 string Surname    = sr.ReadLine();
                 int    the_class  =
                     int.Parse(sr.ReadLine());
                 int yaer =
                     int.Parse(sr.ReadLine());
                 int len =
                     int.Parse(sr.ReadLine());
                 Assessment[] As = new Assessment[len];
                 for (int i = 0; i < len; i++)
                 {
                     string sub = sr?.ReadLine();
                     int    tmpp;
                     int.TryParse(sr?.ReadLine(), out tmpp);
                     Assessment Astmp = new Assessment(sub, tmpp);
                     As[i] = Astmp;
                 }
                 sr?.ReadLine();
                 Schoolboy tmp = new Schoolboy(name, Patronymic, Surname, yaer, the_class, As);
                 list.Add(tmp);
             }
             sr.Close();
             return(list);
         }
     }
     else
     {
         throw new Exception("Такого файла не существует");
     }
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            List_Assessment[] LA = new List_Assessment[11];
            List <Schoolboy>  list;

            //LA = ConsoleMethods.InputSubject();
            do
            {
                list = ConsoleMethods.InputData(ref LA);
            }while (list == null);
            ConsoleMethods.PrintToConsole(list);
            int input;

            do
            {
                Console.WriteLine("Меню" +
                                  "\n1 - Добавить школьников" +
                                  "\n2 - Найти всех отличников" +
                                  "\n3 - Сохранить в файл" +
                                  "\n4 - Изменить данные о школьнике" +
                                  "\n5 - Удалить данные о школьнике" +
                                  "\n0 - Завершение работы");
                int.TryParse(Console.ReadLine(), out input);
                switch (input)
                {
                case 1:
                    if (LA[0] == null)
                    {
                        LA = ConsoleMethods.InputSubject();
                    }
                    list = list.Concat(ConsoleMethods.InputData(ref LA)).ToList();
                    ConsoleMethods.PrintToConsole(list);
                    break;

                case 2:
                    Console.WriteLine("Отличники");
                    int[] Otl = new int[11];
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (list[i].Search_excellent_student())
                        {
                            Otl[list[i].the_class - 1]++;
                            Console.WriteLine(list[i].ToString());
                        }
                    }
                    for (int i = 0; i < 11; i++)
                    {
                        Console.WriteLine("Отличники в " + (i + 1).ToString() + " классе " + Otl[i].ToString());
                    }
                    break;

                case 3:
                    string       name;
                    IFileManager file = ConsoleMethods.ChooseFile(out name);
                    if (file.SaveToFile(list, name))
                    {
                        Console.WriteLine("Запись выполнена");
                    }
                    break;

                case 4:
                    Console.WriteLine("Выберите элемент для изменения, начиная с 0");     //method
                    int numEd;
                    if (LA[0] == null)
                    {
                        LA = ConsoleMethods.InputSubject();
                    }
                    int.TryParse(Console.ReadLine(), out numEd);
                    Schoolboy tmp = new Schoolboy();
                    tmp         = ConsoleMethods.ReadSchoolboy(LA);
                    list[numEd] = tmp;
                    Console.WriteLine("Изменение завершено");
                    Console.ReadLine();
                    ConsoleMethods.PrintToConsole(list);
                    break;

                case 5:
                    Console.WriteLine("Выберите элемент для удаления, начиная с 0 " + "до " + (list.Count - 1).ToString()); //method
                    int numDel;
                    int.TryParse(Console.ReadLine(), out numDel);
                    list.RemoveAt(numDel);
                    Console.WriteLine("Удаление завершено");
                    Console.ReadLine();
                    ConsoleMethods.PrintToConsole(list);
                    break;
                }
            }while (input != 0);
        }