コード例 #1
0
        static void Main(string[] args)
        {
            var st = new Student("name", new DateTime(1998, 2, 25));

            Console.WriteLine(st);
            st.Mark = 100;
            Console.WriteLine(st);
            Student st2 = new Student(_born: new DateTime(1999, 2, 3), _surname: "name");

            Console.WriteLine(st2);
            Student st3 = new Student()
            {
                Born = new DateTime(2000, 1, 1), GenderType = Student.Gender.Female, Mark = 34, Surname = "name"
            };

            Console.WriteLine(st3);
            string[]  arr   = File.ReadAllLines("StudentLst.txt");
            Student[] lst   = new Student[arr.Length];
            int       index = 0;

            foreach (var i in arr)
            {
                string[]       spl  = i.Split(' ');
                Student.Gender male = Student.Gender.Female;
                if (spl[3] == Student.Gender.Male.ToString())
                {
                    male = Student.Gender.Male;
                }
                lst[index++] = new Student(spl[0], DateTime.Parse(spl[1]), double.Parse(spl[2]), male);
            }
            Console.WriteLine();
            IComparer <Student> ic = (IComparer <Student>) new Student("", new DateTime());

            Array.Sort(lst, ic);
            foreach (var i in lst)
            {
                Console.WriteLine(i);
            }
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Alibek15/HW11
        static void Main(string[] args)
        {
            ConsoleKey button;
            int        count = ONE, incomePerFamilyMember;
            bool       isPars, isContinue = true;
            string     fullName, groupName;
            double     avgMark;

            List <Student> students = new List <Student>();
            Student        student  = new Student();

            Student.Gender    gender    = new Student.Gender();
            Student.StudyForm studyForm = new Student.StudyForm();

            while (isContinue == true)
            {
                WriteLine("\nВведите полное имя студента:");
                fullName = ReadLine();

                WriteLine("\nВведите группу студента:");
                groupName = ReadLine();

                WriteLine("\nВведите средний балл:");
                isPars = double.TryParse(ReadLine(), out avgMark);

                WriteLine("\nВведите зарплату на члена семьй:\n");
                isPars = int.TryParse(ReadLine(), out incomePerFamilyMember);


                WriteLine("\nНажимите 1 если вы мужчина, 2 если женщина:\n");
                button = ReadKey().Key;

                if (button == ConsoleKey.D1)
                {
                    gender = Student.Gender.Male;
                }
                else if (button == ConsoleKey.D2)
                {
                    gender = Student.Gender.Female;
                }
                else
                {
                    WriteLine("Не коректный ввод");
                    Environment.Exit(ZERO);
                    ReadKey();
                }

                WriteLine("\nНажимите 1 если вы на очной форме обучение, 2 если на заочной:\n");
                button = ReadKey().Key;

                if (button == ConsoleKey.D1)
                {
                    studyForm = Student.StudyForm.Intramural;
                }
                else if (button == ConsoleKey.D2)
                {
                    studyForm = Student.StudyForm.Correspondence;
                }
                else
                {
                    WriteLine("Не корекнтый ввод");
                    Environment.Exit(ZERO);
                    ReadKey();
                }



                student.FullName              = fullName;
                student.GroupName             = groupName;
                student.AvgMark               = avgMark;
                student.IncomePerFamilyMember = incomePerFamilyMember;
                student.GenderSave            = (int)gender;
                student.StudyFormSave         = (int)studyForm;


                students.Add(student);

                WriteLine("\nНажимите ESC если хотите прекратить ввод данных, если хотите продолжить нажимите на любую кнопку");
                button = ReadKey().Key;

                if (button == ConsoleKey.Escape)
                {
                    isContinue = false;
                }
                else
                {
                    isContinue = true;
                }

                Clear();
            }

            WriteLine("Полный вывод информаций.");
            foreach (Student i in students)
            {
                WriteLine("\n" + count + ".Полное имя студента: " + i.FullName);
                WriteLine("  Группа студента: " + i.GroupName);
                WriteLine("  Средний балл студента:" + i.AvgMark);
                WriteLine("  Зарплата на члена семьй: " + i.IncomePerFamilyMember);
                WriteLine("  Пол студента: " + i.GenderSave);
                WriteLine("  Форма обучение студента:" + i.StudyFormSave);
                count++;
            }
            List <Student> minSalaryStudents = new List <Student>();
            List <Student> avgSortStudents   = new List <Student>();

            foreach (Student i in students)
            {
                if (i.IncomePerFamilyMember < minimumSalaryInKazahstan)
                {
                    minSalaryStudents.Add(i);
                }
                else
                {
                    avgSortStudents.Add(i);
                }
            }
            var sortedStudents = avgSortStudents.OrderBy(u => u.AvgMark);

            count = ONE;

            WriteLine("\nВывод студентов, меньше минимального дохода на члена семьи, для выдачи комнаты.");
            foreach (Student i in minSalaryStudents)
            {
                WriteLine("\n" + count + ".Полное имя студента: " + i.FullName);
                WriteLine("  Группа студента: " + i.GroupName);
                WriteLine("  Средний балл студента:" + i.AvgMark);
                WriteLine("  Зарплата на члена семьй: " + i.IncomePerFamilyMember);
                WriteLine("  Пол студента: " + i.GenderSave);
                WriteLine("  Форма обучение студента:" + i.StudyFormSave);
                count++;
            }

            WriteLine("\nВывод студентов, с высокими баллами, для выдачи комнаты");
            foreach (Student i in minSalaryStudents)
            {
                WriteLine("\n" + count + ".Полное имя студента: " + i.FullName);
                WriteLine("  Группа студента: " + i.GroupName);
                WriteLine("  Средний балл студента:" + i.AvgMark);
                WriteLine("  Зарплата на члена семьй: " + i.IncomePerFamilyMember);
                WriteLine("  Пол студента: " + i.GenderSave);
                WriteLine("  Форма обучение студента:" + i.StudyFormSave);
                count++;
            }
            ReadKey();
        }