//Return a List<Assignment> with the assignments which must submission in the week of a date-----------------------------------------------------------------------------------------------
        public List <Assignment> assignmentsPerWeek(DateTime date)
        {
            List <Assignment> assignmentsOfWeek = new List <Assignment>();
            DateTime          monday            = MyStaticClass.FindTheDateOFMonday(date);
            DateTime          friday            = MyStaticClass.FindTheDateOfFriday(monday);

            foreach (Assignment item in MyDatabase.allAssignments)
            {
                if (item.subDateTime.CompareTo(monday) >= 0 && item.subDateTime.CompareTo(friday) <= 0)
                {
                    assignmentsOfWeek.Add(item);
                }
                item.subDateTime.CompareTo(monday);
            }

            return(assignmentsOfWeek);
        }
Пример #2
0
        //Methods==============================================================================================================
        public void InputStudent()
        {
            string   addAnotherStudent      = "";
            bool     notSucceededTheConvert = true;        //Convert from string to double
            DateTime FalseDate = new DateTime(0001, 1, 1); //Compere for wrong input date


            do
            {
                Student student = new Student();

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine();
                Console.WriteLine("\tNew student");
                Console.ForegroundColor = ConsoleColor.White;


                //Input fields-------------------------------------------------------------------------------------
                Console.WriteLine();
                Console.Write("\tFirst name : ");
                student.firstName = Console.ReadLine();

                Console.Write("\tLast name : ");
                student.lastName = Console.ReadLine();

                do
                {
                    Console.Write("\tDate of birth YYYY/MM/DD : ");
                    student.dateOfBirth = MyStaticClass.InputDate();
                } while (student.dateOfBirth == FalseDate);

                do
                {
                    Console.Write("\tTuition fees : ");

                    try
                    {
                        student.tuitionFees    = Convert.ToDecimal(Console.ReadLine().Replace(".", ","));
                        notSucceededTheConvert = false;
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\tPlease give a right form of fees.");
                        Console.ForegroundColor = ConsoleColor.White;
                        notSucceededTheConvert  = true;
                    }
                } while (notSucceededTheConvert);



                students.Add(student);
                MyDatabase.allStudents.Add(student);

                //Ask to continue--------------------------------------------------------------------------------------
                do
                {
                    Console.WriteLine();
                    Console.Write("\tWould you like to add another student? Y/N : ");
                    addAnotherStudent = Console.ReadLine();
                } while (addAnotherStudent.ToUpper() != "Y" && addAnotherStudent.ToUpper() != "N");
            } while (addAnotherStudent.ToUpper() != "N");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\t=================================================================================\n");
            Console.ForegroundColor = ConsoleColor.White;
        }
        //Methods==============================================================================================================
        public void InputAssignment()
        {
            string   addAnotherAssignment   = "";
            bool     notSucceededTheConvert = true;        //Convert from string to double
            DateTime FalseDate = new DateTime(0001, 1, 1); //Compere for wrong input date

            do
            {
                Assignment assignment = new Assignment();
                bool       isSubmitInWeekentd;

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine();
                Console.WriteLine("\tNew assignment");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.White;

                //Input fields
                Console.WriteLine();
                Console.Write("\tTitle : ");
                assignment.title = Console.ReadLine();

                Console.Write("\tDescription : ");
                assignment.description = Console.ReadLine();

                do
                {
                    Console.Write("\tSubmission date YYYY/MM/DD : ");
                    assignment.subDateTime = MyStaticClass.InputDate();
                    if (assignment.subDateTime.DayOfWeek == DayOfWeek.Saturday || assignment.subDateTime.DayOfWeek == DayOfWeek.Sunday)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\tSubmissions cannot be submitted at the weekend. Enter an appropriate date.");
                        Console.ForegroundColor = ConsoleColor.White;
                        isSubmitInWeekentd      = true;
                    }
                    else
                    {
                        isSubmitInWeekentd = false;
                    }
                } while (assignment.subDateTime == FalseDate || isSubmitInWeekentd);

                do
                {
                    Console.Write("\tOral mark : ");

                    try
                    {
                        assignment.oralMark    = Convert.ToDecimal(Console.ReadLine().Replace(".", ","));
                        notSucceededTheConvert = false;
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\tPlease give a right form of mark.");
                        Console.ForegroundColor = ConsoleColor.White;
                        notSucceededTheConvert  = true;
                    }
                } while (notSucceededTheConvert);

                do
                {
                    Console.Write("\tTotal mark : ");

                    try
                    {
                        assignment.totalMark   = Convert.ToDecimal(Console.ReadLine().Replace(".", ","));
                        notSucceededTheConvert = false;
                    }
                    catch (Exception)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\tPlease give a right form of mark.");
                        Console.ForegroundColor = ConsoleColor.White;
                        notSucceededTheConvert  = true;
                    }
                } while (notSucceededTheConvert);


                assignments.Add(assignment);
                MyDatabase.allAssignments.Add(assignment);

                //Ask to continue
                do
                {
                    Console.WriteLine();
                    Console.Write("\tWould you like to add another assignment? Y/N : ");
                    addAnotherAssignment = Console.ReadLine();
                } while (addAnotherAssignment.ToUpper() != "Y" && addAnotherAssignment.ToUpper() != "N");
            } while (addAnotherAssignment.ToUpper() != "N");

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\n\t=================================================================================\n");
            Console.ForegroundColor = ConsoleColor.White;
        }
Пример #4
0
        //Methods==============================================================================================================
        public void InputCourse()
        {
            string   addAnotherCourse = "";
            DateTime FalseDate        = new DateTime(0001, 1, 1); //Compere for wrong input date

            do
            {
                Course course = new Course();

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine();
                Console.WriteLine("\tNew course");
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.White;

                //Input fields
                Console.WriteLine();
                Console.Write("\tTitle : ");
                course.title = Console.ReadLine();

                Console.Write("\tStream : ");
                course.stream = Console.ReadLine();

                Console.Write("\tType : ");
                course.type = Console.ReadLine();

                do
                {
                    Console.Write("\tStart date YYYY/MM/DD : ");
                    course.startDate = MyStaticClass.InputDate();
                } while (course.startDate == FalseDate);

                do
                {
                    Console.Write("\tEnd date YYYY/MM/DD : ");
                    course.endDate = MyStaticClass.InputDate();

                    if (course.startDate > course.endDate && course.endDate != FalseDate)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\tEnd date can't be before than start date.");
                        Console.ForegroundColor = ConsoleColor.White;
                    }
                } while (course.endDate == FalseDate || course.startDate > course.endDate);

                courses.Add(course);
                MyDatabase.allCourses.Add(course);

                //Ask to continue
                do
                {
                    Console.WriteLine();
                    Console.Write("\tWould you like to add another course? Y/N : ");
                    addAnotherCourse = Console.ReadLine();
                } while (addAnotherCourse.ToUpper() != "Y" && addAnotherCourse.ToUpper() != "N");
            } while (addAnotherCourse.ToUpper() != "N");

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