private static void createData() { Student student1 = (new Student("KONSTANTINA", "LAKOUMENTA", "8/9/1998", 250)); Student student2 = (new Student("GEORGE", "PAPADOPOULOS", "14/4/1995", 300)); Student student3 = new Student("MARIA", "ANTONIOU", "3/11/1990", 400); School.allStudents.Add(student1); School.allStudents.Add(student2); School.allStudents.Add(student3); Course course1 = new Course("C#", "Part time", "Online", "15/2/2021", "15/9/2021"); Course course2 = new Course("Python", "Full time", "Physical presence", "1/3/2021", "1/6/2021"); School.allCourses.Add(course1); School.allCourses.Add(course2); Trainer trainer1 = new Trainer("XRISTOS", "MICHALAKOPOULOS", "Programming"); Trainer trainer2 = new Trainer("AGGELIKI", "ZAXAROPOULOU", "Programming"); Trainer trainer3 = new Trainer("KATERINA", "ATHANASIOU", "Databases"); School.allTrainers.Add(trainer1); School.allTrainers.Add(trainer2); School.allTrainers.Add(trainer3); Assignment ass1 = new Assignment("Project C#", "individual", "31/3/2021", "50", "100"); Assignment ass2 = new Assignment("Project Python", "individual", "27/1/2021", "50", "100"); Assignment ass3 = new Assignment("Database", "group", "15/5/2021", "30", "100"); School.allAssignment.Add(ass1); School.allAssignment.Add(ass2); School.allAssignment.Add(ass3); //StudentsPerCourse StudentsPerCourse spc1 = new StudentsPerCourse(course1, new List <Student>() { student1, student2 }); StudentsPerCourse spc2 = new StudentsPerCourse(course2, new List <Student>() { student2, student3 }); School.CourseAttendees.Add(spc1); School.CourseAttendees.Add(spc2); //TrainersPerCourse TrainersPerCourse tpc1 = new TrainersPerCourse(course1, new List <Trainer>() { trainer1, trainer3 }); TrainersPerCourse tpc2 = new TrainersPerCourse(course2, new List <Trainer>() { trainer2, trainer3 }); School.CourseTrainers.Add(tpc1); School.CourseTrainers.Add(tpc2); //AssignmentsPerCourse AssignmentsPerCourse apc1 = new AssignmentsPerCourse(course1, new List <Assignment>() { ass1, ass3 }); AssignmentsPerCourse apc2 = new AssignmentsPerCourse(course2, new List <Assignment>() { ass2, ass3 }); School.CourseAssignments.Add(apc1); School.CourseAssignments.Add(apc2); //CoursesPerStudent CoursesPerStudent cps1 = new CoursesPerStudent(student1, new List <Course>() { course1 }); CoursesPerStudent cps2 = new CoursesPerStudent(student2, new List <Course>() { course1, course2 }); CoursesPerStudent cps3 = new CoursesPerStudent(student3, new List <Course>() { course2 }); School.StudentCourses.Add(cps1); School.StudentCourses.Add(cps2); School.StudentCourses.Add(cps3); }
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(); }
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); } }
public static void AddTrainerInList(Trainer trainer) { allTrainers.Add(trainer); }