Beispiel #1
0
        static void Main(string[] args)
        {
            List<Student> students = new List<Student>();
            Community community = new Community();
            Random rnd = new Random();

            Console.WriteLine("Сколько студентов вы хотите добавить в список на получение общежития?");
            int size = int.Parse(Console.ReadLine());

            for (int i = 0; i < size; i++)
            {
                Student student = new Student();
                student.Family = new List<Family>();
                int localNum = rnd.Next(40, 100);
                int Gen = rnd.Next(1,10);
                int formGen = rnd.Next(1,3);

                student.FullName = string.Format("FullName_{0}", rnd.Next(1,100));
                student.Class = string.Format("Class_{0}", rnd.Next(1, 10));
                switch (Gen)
                {
                    case 1:
                        {
                            student.Gen = Gender.female;
                        }
                        break;
                    case 2:
                        {
                            student.Gen = Gender.male;
                        }
                        break;
                    case 3:
                        {
                            student.Gen = Gender.McDonnellDouglasAH64Apache;
                        }
                        break;
                    case 4:
                        {
                            student.Gen = Gender.покемон;
                        }
                        break;
                    default:
                        break;
                }
                switch (formGen)
                {
                    case 1:
                        {
                            student.FormOfEducation = Forms.Онлайн;
                        }
                        break;
                    case 2:
                        {
                            student.FormOfEducation = Forms.Очное;
                        }
                        break;
                    case 3:
                        {
                            student.FormOfEducation = Forms.Заочное;
                        }
                        break;
                    default:
                        break;
                }
                List<int> badNum = new List<int>();
                for (int j = 0; j < Gen; j++)
                {
                    Family person = new Family();
                    int relativeGen = rnd.Next(1, 4);
                    if (!badNum.Contains(relativeGen))
                    {
                        switch (relativeGen)
                        {
                            case 1:
                                {
                                    person.Relative = Relative.Брат;
                                    person.RelativesIncome = rnd.Next(20000, 80000);
                                    person.Age = rnd.Next(18, 23);
                                    person.FullName = string.Format("FullName_{0}", rnd.Next(1, 100));
                                }
                                break;
                            case 2:
                                {
                                    person.Relative = Relative.Мать;
                                    person.RelativesIncome = rnd.Next(200000, 400000);
                                    person.Age = rnd.Next(50, 70);
                                    person.FullName = string.Format("FullName_{0}", rnd.Next(1, 100));
                                }
                                break;
                            case 3:
                                {
                                    person.Relative = Relative.Отец;
                                    person.RelativesIncome = rnd.Next(200000, 400000);
                                    person.Age = rnd.Next(50, 70);
                                    person.FullName = string.Format("FullName_{0}", rnd.Next(1, 100));
                                }
                                break;
                            case 4:
                                {
                                    person.Relative = Relative.Сестра;
                                    person.RelativesIncome = rnd.Next(20000, 80000);
                                    person.Age = rnd.Next(18, 23);
                                    person.FullName = string.Format("FullName_{0}", rnd.Next(1, 100));
                                }
                                break;
                            default:
                                break;
                        }
                        badNum.Add(relativeGen);
                        student.Family.Add(person);
                    }
                }
                
                students.Add(student);
            }

            Student.ShowStudents(students);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            community.AddStudent(students, community);
        }