コード例 #1
0
        public void InputTrainersPerCourse(Course course, string userInput)
        {
            bool    notSuccededAdd = true;
            Trainer trainer        = new Trainer();

            this.course = course;

            if (userInput == "1") //new trainer
            {
                trainer.InputTrainer();
                course.trainers.AddRange(trainer.trainers);

                foreach (var item in trainer.trainers)
                {
                    item.courses.Add(course);
                }
            }
            else if (userInput == "2")// existing trainer
            {
                do
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine();
                    Console.WriteLine("\tSelect the number of trainer.");
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.White;

                    trainer.ListOfTrainersOutput(MyDatabase.allTrainers);

                    do
                    {
                        try
                        {
                            Console.WriteLine();
                            Console.Write("\tEnter a propriate number : ");
                            userSelectTrainer = Convert.ToInt32(Console.ReadLine());

                            if (userSelectTrainer <= MyDatabase.allTrainers.Count && userSelectTrainer > 0)
                            {
                                trainersPerCourse.Add(MyDatabase.allTrainers[userSelectTrainer - 1]);
                                notSuccededAdd = false;
                            }
                            else
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("\tPlease select a propriate number.");
                                Console.ForegroundColor = ConsoleColor.White;
                                notSuccededAdd          = true;
                            }
                        }
                        catch (Exception)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("\tPlease select a propriate number.");
                            Console.ForegroundColor = ConsoleColor.White;
                            notSuccededAdd          = true;
                        }
                    } while (notSuccededAdd);

                    //Ask to add another trainer from the list in course
                    do
                    {
                        Console.WriteLine();
                        Console.Write("\tWould you like to add another trainer from the list in course? Y/N : ");
                        addAnotherTrainerfromList = Console.ReadLine();
                        Console.WriteLine();
                    } while (addAnotherTrainerfromList.ToUpper() != "Y" && addAnotherTrainerfromList.ToUpper() != "N");
                } while (addAnotherTrainerfromList.ToUpper() != "N");

                course.trainers.AddRange(trainersPerCourse);

                foreach (var item in trainersPerCourse)
                {
                    item.courses.Add(course);
                }

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\n\t=================================================================================\n");
                Console.ForegroundColor = ConsoleColor.White;

                trainersPerCourse.Clear();
            }
        }
コード例 #2
0
 public TrainerPerCourse(Course course, Trainer tr)
 {
     Course = course;
     trainersInCourse.Add(tr);
 }
コード例 #3
0
        public void Start()                                  // Η Αρχη του προγράμματος
        {
            bool   end = false;
            string input;

            Console.WriteLine("--------- This is a private school structure ----------"); //Title
            do
            {
                Console.WriteLine("Press 1 to insert data or press 2 to use synthetic"); //Choice between Manual or Synthetic
                input = Console.ReadLine();
            } while (input != "1" && input != "2");
            if (input == "1")                               // If Manual Entry
            {
                Console.WriteLine("Press 1 if you want to add a student");
                Console.WriteLine("Press 2 if you want to add a trainer");
                Console.WriteLine("Press 3 if you want to add a course");
                Console.WriteLine("Press 4 if you want to add an Assignment");
                Console.WriteLine("Press anything if you want to exit the application");
                string choice = Console.ReadLine();
                Console.WriteLine();
                switch (choice)
                {
                case "1":                                   //Insert Student
                    Console.WriteLine("Please insert the first name of the student");
                    string studentfirst = Console.ReadLine();
                    Console.WriteLine("Please insert the last name of the student");
                    string studentlast = Console.ReadLine();
                    Console.WriteLine("Please insert the date of birth of the student in the following output yyyy/mm/dd");
                    DateTime dateofbirth = Convert.ToDateTime(Console.ReadLine());
                    Console.WriteLine("Please insert the student's tuition fees");
                    decimal fees = Convert.ToDecimal(Console.ReadLine());
                    Console.WriteLine();
                    Student student = new Student(studentfirst, studentlast, dateofbirth, fees);
                    Console.WriteLine(student);
                    break;

                case "2":                                   // Insert Trainer
                    Console.WriteLine("Please insert the first name of the trainer");
                    string trainerfirst = Console.ReadLine();
                    Console.WriteLine("Please insert the last name of the trainer");
                    string trainerlast = Console.ReadLine();
                    Console.WriteLine("Please insert the subject of the trainer");
                    string trainersubj = Console.ReadLine();
                    Console.WriteLine();
                    Trainer trainer = new Trainer(trainerfirst, trainerlast, trainersubj);
                    Console.WriteLine(trainer);
                    break;

                case "3":                                   // Insert Course
                    Console.WriteLine("Please insert the title of the course");
                    string coursetitle = Console.ReadLine();
                    Console.WriteLine("Please insert the stream of the course");
                    string coursestream = Console.ReadLine();
                    Console.WriteLine("Please insert the type of the course");
                    string coursetype = Console.ReadLine();
                    Console.WriteLine("Please insert the start date of the course yyyy/mm/dd");
                    DateTime coursesubdate = Convert.ToDateTime(Console.ReadLine());
                    Console.WriteLine("Please insert the end date the course in format yyyy/mm/dd");
                    DateTime courseenddate = Convert.ToDateTime(Console.ReadLine());
                    Console.WriteLine();
                    Course course = new Course(coursetitle, coursestream, coursetype, coursesubdate, courseenddate);
                    Console.WriteLine(course);
                    break;

                case "4":                                   //Insert Assignment
                    Console.WriteLine("Please insert the title of the assignment");
                    string assigntitle = Console.ReadLine();
                    Console.WriteLine("Please insert the description of the assignment");
                    string assigndesc = Console.ReadLine();
                    Console.WriteLine("Please insert the subdate time of the assignment in format yyyy/mm/dd");
                    DateTime subdate = Convert.ToDateTime(Console.ReadLine());
                    Console.WriteLine("Please insert the oral mark of the assignment");
                    decimal oralmark = Convert.ToDecimal(Console.ReadLine());
                    Console.WriteLine("Please insert the total mark of the assignment");
                    decimal    totalmark  = Convert.ToDecimal(Console.ReadLine());
                    Assignment assignment = new Assignment(assigntitle, assigndesc, subdate, oralmark, totalmark);
                    Console.WriteLine(assignment);
                    break;

                default:
                    break;
                }
                while (!end)
                {
                    ;
                }
            }
            else if (input == "2")                          // If Synthetic
            {
                do
                {
                    Console.WriteLine("Press 1 for a list of students");
                    Console.WriteLine("Press 2 for a list of trainers");
                    Console.WriteLine("Press 3 for a list of Courses");
                    Console.WriteLine("Press 4 for a list of Assignments");
                    Console.WriteLine("Press 5 for a list of Students Per Course");
                    Console.WriteLine("Press anything else if you want to exit the application");
                    string choice = Console.ReadLine();
                    switch (choice)
                    {
                    case "1":                               //Synthetic Students
                        Console.WriteLine("---------------The students of the school are: ---------------");
                        SyntheticStudents();
                        Console.WriteLine();
                        break;

                    case "2":                               //Synthetic Trainers
                        Console.WriteLine("---------------The trainers of the school are: ---------------");
                        SyntheticTrainers();
                        Console.WriteLine();
                        break;

                    case "3":                               //Synthetic Courses
                        Console.WriteLine("---------------The courses of the school are: ---------------");
                        SyntheticCourses();
                        Console.WriteLine();
                        break;

                    case "4":                               //Synthetic Assignments
                        Console.WriteLine("---------------The assignments of the school are: ---------------");
                        SyntheticAssignments();
                        Console.WriteLine();
                        break;

                    case "5":                               //Synthetic Student per Course
                        Console.WriteLine("-------In the C# Full time course-------");
                        StudentsPerCourseCsharpFull();
                        Console.WriteLine();
                        Console.WriteLine("-------In the C# Part time Course-------");
                        StudentsPerCourseCsharpPart();
                        Console.WriteLine();
                        Console.WriteLine("-------In the Java Full time Course-------");
                        StudentsPerCourseJavaFull();
                        Console.WriteLine();
                        Console.WriteLine("-------In the Java Part time Course-------");
                        StudentsPerCourseJavaPart();
                        Console.WriteLine();
                        break;

                    default:
                        end = true;                         //End
                        break;
                    }
                } while (!end);
            }
            Console.WriteLine("Press any key to exit the application");
        }
コード例 #4
0
        public static void SyntheticDataDatabaseBild()
        {
            //Bild Data---------------------------------------------------------------------------------------------------------------------------
            Student s1  = new Student(firstName: "Maria", lastName: "Fafouti", dateOfBirth: DateTime.Parse("1990/7/1"), tuitionFees: 500);
            Student s2  = new Student(firstName: "Evangelos", lastName: "Koutsogiorgos", dateOfBirth: DateTime.Parse("1989/11/9"), tuitionFees: 1000);
            Student s3  = new Student(firstName: "Panagiotis", lastName: "Koutsogiorgos", dateOfBirth: DateTime.Parse("1991/3/26"), tuitionFees: 600);
            Student s4  = new Student(firstName: "Ioannis", lastName: "Angelopoulos", dateOfBirth: DateTime.Parse("1985/6/19"), tuitionFees: 500);
            Student s5  = new Student(firstName: "Sophia", lastName: "Georgiou", dateOfBirth: DateTime.Parse("1992/6/13"), tuitionFees: 700);
            Student s6  = new Student(firstName: "Eleni", lastName: "Parisi", dateOfBirth: DateTime.Parse("1989/12/3"), tuitionFees: 1200);
            Student s7  = new Student(firstName: "Eleutherios", lastName: "Danopoulos", dateOfBirth: DateTime.Parse("1992/1/14"), tuitionFees: 500);
            Student s8  = new Student(firstName: "Dimitra", lastName: "Alexiou", dateOfBirth: DateTime.Parse("1991/10/29"), tuitionFees: 900);
            Student s9  = new Student(firstName: "George", lastName: "Leras", dateOfBirth: DateTime.Parse("1990/8/13"), tuitionFees: 1100);
            Student s10 = new Student(firstName: "Thanasis", lastName: "Sdralias", dateOfBirth: DateTime.Parse("1985/5/13"), tuitionFees: 800);

            Course c1 = new Course(title: "Chem", stream: "Full time", type: "Chemistry", startDate: DateTime.Parse("2019/10/1"), endDate: DateTime.Parse("2020/6/16"));
            Course c2 = new Course(title: "Phys", stream: "Full time", type: "Physics", startDate: DateTime.Parse("2019/10/1"), endDate: DateTime.Parse("2020/6/23"));

            Trainer t1 = new Trainer(firstName: "Marie", lastName: "Curie", subject: "Chemistry");
            Trainer t2 = new Trainer(firstName: "Luis", lastName: "Pasteur", subject: "Chemistry");
            Trainer t3 = new Trainer(firstName: "Albert", lastName: "Einstain", subject: "Physics");
            Trainer t4 = new Trainer(firstName: "Richard", lastName: "Faynman", subject: "Physics");

            Assignment a1 = new Assignment(title: "OrgChem", description: "Organic Chemistry", subDateTime: DateTime.Parse("2020/1/10"), oralMark: 77, totalMark: 88);
            Assignment a2 = new Assignment(title: "InorgChem", description: "Inorganic Chemistry", subDateTime: DateTime.Parse("2020/1/9"), oralMark: 65, totalMark: 92);
            Assignment a3 = new Assignment(title: "MecPhys", description: "Mecanics", subDateTime: DateTime.Parse("2020/1/23"), oralMark: 69, totalMark: 72);
            Assignment a4 = new Assignment(title: "OptPhys", description: "Optics", subDateTime: DateTime.Parse("2020/1/20"), oralMark: 83, totalMark: 75);

            syntheticStudents.Add(s1);
            syntheticStudents.Add(s2);
            syntheticStudents.Add(s3);
            syntheticStudents.Add(s4);
            syntheticStudents.Add(s5);
            syntheticStudents.Add(s6);
            syntheticStudents.Add(s7);
            syntheticStudents.Add(s8);
            syntheticStudents.Add(s9);
            syntheticStudents.Add(s10);

            syntheticCorses.Add(c1);
            syntheticCorses.Add(c2);

            syntheticTrainers.Add(t1);
            syntheticTrainers.Add(t2);
            syntheticTrainers.Add(t3);
            syntheticTrainers.Add(t4);

            syntheticAssignmets.Add(a1);
            syntheticAssignmets.Add(a2);
            syntheticAssignmets.Add(a3);
            syntheticAssignmets.Add(a4);

            //Give structure at private school-------------------------------------------------------------------------------------------------------------------
            //Put students at courses
            c1.students.Add(s1);
            c1.students.Add(s2);
            c1.students.Add(s3);
            c1.students.Add(s4);
            c1.students.Add(s5);
            c2.students.Add(s1);
            c2.students.Add(s2);
            c2.students.Add(s6);
            c2.students.Add(s7);
            c2.students.Add(s8);
            c2.students.Add(s9);
            c2.students.Add(s10);

            //Put corses at students
            s1.courses.Add(c1);
            s2.courses.Add(c1);
            s1.courses.Add(c2);
            s2.courses.Add(c2);
            s3.courses.Add(c1);
            s4.courses.Add(c1);
            s5.courses.Add(c1);
            s6.courses.Add(c2);
            s7.courses.Add(c2);
            s8.courses.Add(c2);
            s9.courses.Add(c2);
            s10.courses.Add(c2);

            //Put trainers at courses
            c1.trainers.Add(t1);
            c1.trainers.Add(t2);
            c2.trainers.Add(t3);
            c2.trainers.Add(t4);

            //put courses at trainers
            t1.courses.Add(c1);
            t2.courses.Add(c1);
            t3.courses.Add(c2);
            t4.courses.Add(c2);

            //put assignments at courses
            c1.assignments.Add(a1);
            c1.assignments.Add(a2);
            c2.assignments.Add(a3);
            c2.assignments.Add(a4);

            //put courses at assignments
            a1.courses.Add(c1);
            a2.courses.Add(c1);
            a3.courses.Add(c2);
            a4.courses.Add(c2);

            //Put students at assignments
            a1.students.Add(s1);
            a1.students.Add(s2);
            a1.students.Add(s3);
            a1.students.Add(s4);
            a1.students.Add(s5);
            a2.students.Add(s1);
            a2.students.Add(s2);
            a2.students.Add(s3);
            a2.students.Add(s4);
            a2.students.Add(s5);

            a3.students.Add(s6);
            a3.students.Add(s7);
            a3.students.Add(s8);
            a3.students.Add(s9);
            a3.students.Add(s10);
            a4.students.Add(s6);
            a4.students.Add(s7);
            a4.students.Add(s8);
            a4.students.Add(s9);
            a4.students.Add(s10);

            //Put assignmets at students
            s1.assignments.Add(a1);
            s2.assignments.Add(a1);
            s3.assignments.Add(a1);
            s4.assignments.Add(a1);
            s5.assignments.Add(a1);
            s1.assignments.Add(a2);
            s2.assignments.Add(a2);
            s3.assignments.Add(a2);
            s4.assignments.Add(a2);
            s5.assignments.Add(a2);

            s6.assignments.Add(a3);
            s7.assignments.Add(a3);
            s8.assignments.Add(a3);
            s9.assignments.Add(a3);
            s10.assignments.Add(a3);
            s6.assignments.Add(a4);
            s7.assignments.Add(a4);
            s8.assignments.Add(a4);
            s9.assignments.Add(a4);
            s10.assignments.Add(a4);
        }