Beispiel #1
0
 private static void firstMenu()
 {
     Console.WriteLine("Add the student(s).");
     Student.addStudent(false);
     Console.WriteLine("Add the course(s).");
     Course.addCourses(false);
     School.MatchStudentsCourses();
     Console.WriteLine("Add the trainer(s).");
     Trainer.addTrainers(false);
     School.MatchTrainersCourses();
     Console.WriteLine("Add the assignment(s).");
     Assignment.addAssignment(false);
     School.MatchAssignmentsCourses();
 }
Beispiel #2
0
        private static bool Menu()
        {
            Console.WriteLine("\n--------Choose an option:--------\n");
            Console.WriteLine("1)Add extra students");
            Console.WriteLine("2)Print a list of student\n");
            Console.WriteLine("3)Add extra courses");
            Console.WriteLine("4)Print a list of courses.\n");
            Console.WriteLine("5)Add extra trainers");
            Console.WriteLine("6)Print a list of trainers\n");
            Console.WriteLine("7)Add extra assignments");
            Console.WriteLine("8)Print a list of assignments \n");
            Console.WriteLine("9)Print all the student per courses.");
            Console.WriteLine("10)Print all the trainers per course.");
            Console.WriteLine("11)Print all the assignements per course.");
            Console.WriteLine("12)Print all the assignments per student.");
            Console.WriteLine("13)Print a list of students that belong to more than one courses");
            Console.WriteLine("14)Print a list of students who need to submit one or more assignments on the same calemndar week.");
            Console.WriteLine("\n15) Make new matches");
            Console.WriteLine("16)Exit\n");

            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                Console.Clear();
                Student.addStudent(false);
                return(true);

            case "2":
                Console.Clear();
                School.PrintStudents();
                return(true);

            case "3":
                Console.Clear();
                Course.addCourses(false);
                School.MatchStudentsCourses();
                return(true);

            case "4":
                Console.Clear();
                School.PrintCourses();
                return(true);

            case "5":
                Console.Clear();
                Trainer.addTrainers(false);
                School.MatchTrainersCourses();
                return(true);

            case "6":
                Console.Clear();
                School.PrintTrainers();
                return(true);

            case "7":
                Console.Clear();
                Assignment.addAssignment(false);
                School.MatchAssignmentsCourses();
                return(true);

            case "8":
                Console.Clear();
                School.PrintAssignment();
                return(true);

            case "9":
                Console.Clear();
                School.PrintStudentsPerCourses();
                return(true);

            case "10":
                Console.Clear();
                School.PrintTrainersPerCourses();
                return(true);

            case "11":
                Console.Clear();
                School.PrintAssignmentsPerCourses();
                return(true);

            case "12":
                Console.Clear();
                School.MatchCoursesStudent();
                School.PrintAssignmentsPerStudent();
                return(true);

            case "13":
                School.MatchCoursesStudent();
                School.PrintStudentsWithMoreCourses();
                return(true);

            case "14":
                Console.Clear();
                School.SubmitThisWeek();
                return(true);

            case "15":
                Console.Clear();
                bool showMenu = true;
                while (showMenu)
                {
                    showMenu = MenuMatches();
                }
                return(true);

            case "16":
                return(false);

            default:
                return(true);
            }
        }
Beispiel #3
0
        public static void MatchTrainersCourses()       //Matches the Course with all the trainers
        {
            //print the existing trainers and courses
            Console.Clear();
            Console.WriteLine("--------Trainers that already exists--------");
            PrintTrainers();
            Console.WriteLine("\n--------Courses that already exists--------");
            PrintCourses();
            Console.WriteLine("\n\nWrite the titles of the courses and the fullname of trainers that they teaching it");
            Console.WriteLine("Write finish when you are done");
            Console.WriteLine("For example: Chemistry : fullname , fullname...\n");
            bool firstTime = true;

            while (true)
            {
                if (!firstTime)
                {
                    //reminder for next user input
                    Console.WriteLine("\nWrite the next course and trainers or 'finish'");
                }
                string input = Console.ReadLine().Trim();

                if (input.ToLower() == "finish")
                {
                    break;
                }

                //Split and clean user input for further use
                string[] words        = input.Split(':');
                string   title        = words[0].Trim();
                string   names        = words[1];
                bool     courseExists = false;
                Course   course       = null;

                //Check if given Course already exists
                for (int i = 0; i < allCourses.Count; i++)
                {
                    if (title == allCourses[i].title)
                    {
                        course       = allCourses[i];
                        courseExists = true;
                        break;
                    }
                }
                //If not ask user to insert it
                if (!courseExists)
                {
                    Console.WriteLine($"\nThe course {title} is not in list.Do you want to insert it? ('Yes' or 'No')");
                    if (Console.ReadLine().ToLower().Trim() == "yes")
                    {
                        Course.addCourses(true);
                        course = allCourses[allCourses.Count - 1];
                    }
                    else
                    {
                        //if user doesn't want to insert the course, Continue with the next match
                        Console.WriteLine("\nWrite the title of the next course and the fullname of students that they attend it");
                        continue;
                    }
                }

                //Split the inserted names
                string[]       eachName    = names.Split(',');
                List <Trainer> trainers    = new List <Trainer>();
                bool           matchExists = false;

                //Check if the Course has already trainers
                for (int i = 0; i < CourseTrainers.Count; i++)
                {
                    if (title == CourseTrainers[i].course.title)
                    {
                        //if it has, add the extra trainer to the trainers list
                        matchExists = true;
                        foreach (var item in eachName)
                        {
                            //Split the name of its Trainer and Clear
                            string[] trainer = item.Trim().Split();
                            string   fName   = trainer[0].ToUpper();
                            string   lName   = trainer[1].ToUpper();
                            bool     trainerAlreadyInList = false;
                            bool     trainerExists        = false;

                            for (int k = 0; k < allTrainers.Count; k++)
                            {
                                if (fName == allTrainers[k].firstName && lName == allTrainers[k].lastName)        //Check if the trainer exists in allStudents
                                {
                                    trainerExists = true;
                                    break;
                                }
                            }
                            //If not ask user to insert it
                            if (!trainerExists)
                            {
                                Console.WriteLine($"\nThe trainer {fName} {lName} is not in list. Do you want to insert it? (Yes or No)");
                                if (Console.ReadLine().ToLower() == "yes")
                                {
                                    Trainer.addTrainers(true);
                                }
                            }

                            for (int x = 0; x < CourseTrainers[i].trainers.Count; x++)
                            {
                                if (fName == CourseTrainers[i].trainers[x].firstName && lName == CourseTrainers[i].trainers[x].lastName)    //check if the trainer is already in the list of trainers
                                {
                                    trainerAlreadyInList = true;
                                    break;
                                }
                            }
                            if (!trainerAlreadyInList) //if not in list
                            {
                                for (int j = 0; j < allTrainers.Count; j++)
                                {
                                    if (fName == allTrainers[j].firstName && lName == allTrainers[j].lastName)
                                    {
                                        CourseTrainers[i].trainers.Add(allTrainers[j]);   //Add the trainer in the list of trainers
                                        break;
                                    }
                                }
                            }
                        }

                        break;
                    }
                }
                //if the course has not trainers
                if (!matchExists)
                {
                    foreach (var item in eachName)
                    {
                        //Split and clean user input for further use
                        string[] trainer       = item.Trim().Split();
                        string   fName         = trainer[0].ToUpper();
                        string   lName         = trainer[1].ToUpper();
                        bool     TrainerExists = false;

                        //Check if given Trainer already exists
                        for (int i = 0; i < School.allTrainers.Count; i++)
                        {
                            if (fName == School.allTrainers[i].firstName && lName == School.allTrainers[i].lastName)
                            {
                                trainers.Add(School.allTrainers[i]);
                                TrainerExists = true;
                                break;
                            }
                        }
                        //If not ask user to insert it
                        if (!TrainerExists)
                        {
                            Console.WriteLine($"\nThe trainer {fName} {lName} is not in list.Do you want to insert it? (Yes or No)");
                            if (Console.ReadLine().ToLower() == "yes")
                            {
                                Trainer.addTrainers(true);
                                trainers.Add(School.allTrainers[allTrainers.Count - 1]);
                            }
                            else
                            {
                                continue;
                            }
                        }
                    }
                    //Create the object TrainersPerCourse and add it to the list
                    School.CourseTrainers.Add(new TrainersPerCourse(course, trainers));
                }
                firstTime = false;
            }
            Console.Clear();
        }