コード例 #1
0
        public List <Students_Course> DatabaseStudentsCourse(List <Student> students, List <Course> courses)
        {
            List <Student> StudentsListCFT = new List <Student>();

            StudentsListCFT.Add(students[0]); StudentsListCFT.Add(students[2]);
            List <Student> StudentsListCPT = new List <Student>();

            StudentsListCPT.Add(students[1]); StudentsListCPT.Add(students[3]);
            List <Student> StudentsListJFT = new List <Student>();

            StudentsListJFT.Add(students[4]);
            List <Student> StudentsListJPT = new List <Student>();

            StudentsListJPT.Add(students[5]); StudentsListJPT.Add(students[6]);

            Students_Course SC1 = new Students_Course(StudentsListCFT, courses[0]);
            Students_Course SC2 = new Students_Course(StudentsListCPT, courses[1]);
            Students_Course SC3 = new Students_Course(StudentsListJFT, courses[2]);
            Students_Course SC4 = new Students_Course(StudentsListJPT, courses[3]);
            Students_Course SC5 = new Students_Course(DatabaseStudents(), courses[4]);

            List <Students_Course> listofstudents_courses = new List <Students_Course>();

            listofstudents_courses.Add(SC1); listofstudents_courses.Add(SC2); listofstudents_courses.Add(SC3);
            listofstudents_courses.Add(SC4); listofstudents_courses.Add(SC5);

            return(listofstudents_courses);
        }
コード例 #2
0
        public static Students_Course CourseStudents(List <Course> courses, List <Student> students)
        {
            Console.WriteLine("Start with students and courses.");
            Console.WriteLine("Choose a course from the list below by typing it's number");
            CourseTitles(courses);
            Console.WriteLine();
            Console.Write("Enter the number of the course: ");
            Course courseselected = courses[Convert.ToInt32(Console.ReadLine()) - 1];

            Console.WriteLine();
            Console.WriteLine("Choose students from the list below by typing it's number");
            StudentTitles(students);
            Console.WriteLine();
            Console.Write("Enter the number of the student/students with a comma (,) between: ");
            string Choice = Console.ReadLine();

            Choice = Choice.Replace(",", "");
            int[] Choices = new int[Choice.Length];

            for (int i = 0; i < Choice.Length; i++)
            {
                Choices[i] = Convert.ToInt32(Choice[i] - '0');
            }


            List <Student> listofstudents_Chosen = new List <Student>();

            foreach (var item in Choices)
            {
                listofstudents_Chosen.Add(students[item - 1]);
            }

            Students_Course SC1 = new Students_Course(listofstudents_Chosen, courseselected);

            return(SC1);
        }