示例#1
0
        //case 2: Check
        public void FuntionCheckInformation()
        {
            var interFace = new InterfaceOfUser();

            interFace.HeaderOfTableOfInformation();
            foreach (Student item in Students)
            {
                item.ReturnInformationOfAStudent();
            }
        }
示例#2
0
        //case 7: Calculate Averages
        public void CalculateAverages()
        {
            var interFace = new InterfaceOfUser();

            foreach (Student item in Students)
            {
                interFace.HeaderOfTableOfInformation();
                item.ReturnInformationOfAStudent();
                Console.WriteLine("Average Grade is: " + item.CalculateAverageGrade() + "\n");
            }
        }
        public int EnterNumberOfStudent()
        {
            var interFace = new InterfaceOfUser();
            int Number;

            Console.Write("Enter number of students: ");
            do
            {
                string NumberOfStudentWantToAdd = Console.ReadLine();
                Number = interFace.CheckAndReturn(NumberOfStudentWantToAdd);
            } while (Number == -1);
            return(Number);
        }
        public int EnterNumberOfGrades()
        {
            var interFace = new InterfaceOfUser();
            int NumberOfGrade;

            Console.Write("Enter number of grades (1-->2): ");
            do
            {
                string NumberOfGradeWantToAdd = Console.ReadLine();
                NumberOfGrade = interFace.CheckAndReturn(NumberOfGradeWantToAdd);
            } while (NumberOfGrade == -1);
            return(NumberOfGrade);
        }
        public string GetId(List <Student> students)
        {
            var    interFace = new InterfaceOfUser();
            string checkId;
            string ID;

            Console.Write("ID is: ");
            do
            {
                ID      = Console.ReadLine();
                checkId = interFace.CheckEnterId(ID, students);
            } while (checkId != ID);
            return(ID);
        }
示例#6
0
        //Case 5: Find fail grades
        public void FindFailGrade()
        {
            var interFace = new InterfaceOfUser();

            interFace.HeaderOfTableOfInformation();
            foreach (Student item in Students)
            {
                float AverageGrade = item.CalculateAverageGrade();
                if (AverageGrade < 5)
                {
                    item.ReturnInformationOfAStudent();
                    Console.WriteLine("Average grade is: " + AverageGrade);
                }
            }
        }
        public List <float> GetGrade()
        {
            var interFace = new InterfaceOfUser();
            int numberOfGrades;

            do
            {
                numberOfGrades = interFace.CheckNumberOfGrade(EnterNumberOfGrades());
            } while (numberOfGrades == 0);
            List <float> Grades = new List <float>();

            for (var i = 0; i < numberOfGrades; i++)
            {
                Console.Write("Grade " + (i + 1) + ": ");
                float grade = float.Parse(Console.ReadLine());
                Grades.Add(grade);
            }
            return(Grades);
        }
示例#8
0
        //Case 8: Delete student
        public void DeleteStudentById()
        {
            var    EnterID    = new EnterInformation();
            var    InterFace  = new InterfaceOfUser();
            string IdToDelete = EnterID.EnterIdToFind();

            if (InterFace.IsIdExist(IdToDelete, Students) == true)
            {
                Console.WriteLine("Student does not exist");
            }
            else
            {
                foreach (Student student in Students)
                {
                    Students.RemoveAll(s => string.Compare(s.Id, IdToDelete, true) == 0);
                    Console.WriteLine("Deleted");
                    break;
                }
            }
        }
示例#9
0
        //case 4: Find Student has highest grade
        public void FindStudentsHaveHighestAverageGrade()
        {
            float        highestGrade;
            var          interFace        = new InterfaceOfUser();
            List <float> AverageGradeTemp = new List <float>();

            foreach (Student item in Students)
            {
                AverageGradeTemp.Add(item.CalculateAverageGrade());
            }
            AverageGradeTemp.Sort();
            highestGrade = AverageGradeTemp[AverageGradeTemp.Count - 1];
            foreach (Student item in Students)
            {
                if (highestGrade == item.CalculateAverageGrade())
                {
                    Console.WriteLine("Hightest average Grade is: " + highestGrade);
                    interFace.HeaderOfTableOfInformation();
                    item.ReturnInformationOfAStudent();
                }
            }
        }
示例#10
0
        //case 3: Find student
        public void FindByID()
        {
            var    enterInfor = new EnterInformation();
            var    InterFace  = new InterfaceOfUser();
            string idFind     = enterInfor.EnterIdToFind();

            Console.Clear();
            if (InterFace.IsIdExist(idFind, Students) == true)
            {
                Console.WriteLine("Not Found");
            }
            else
            {
                InterFace.HeaderOfTableOfInformation();
                foreach (Student item in Students)
                {
                    if (item.Id == idFind)
                    {
                        item.ReturnInformationOfAStudent();
                    }
                }
            }
        }
示例#11
0
        public void Active()
        {
            ClassRoom Classes = new ClassRoom();
            char      askToContinue;
            var       enterChoice = new EnterInformation();
            var       interFace   = new InterfaceOfUser();
            int       optionItem;
            int       isStudentExist;
            string    userInput;

            do
            {
                interFace.MainMenu();
                do
                {
                    userInput  = enterChoice.EnterUserInput();
                    optionItem = interFace.CheckAndReturn(userInput);
                } while (optionItem == -1);
                switch (optionItem)
                {
                case 1:
                    Console.Clear();
                    Classes.GetInformationOfGroup();
                    break;

                case 2:
                    Console.Clear();
                    isStudentExist = interFace.CheckStudentExist(Classes.Students.Count);
                    if (isStudentExist != 0)
                    {
                        Classes.FuntionCheckInformation();
                        break;
                    }
                    else
                    {
                        break;
                    }

                case 3:
                    Console.Clear();
                    isStudentExist = interFace.CheckStudentExist(Classes.Students.Count);
                    if (isStudentExist == 0)
                    {
                        break;
                    }
                    else
                    {
                        Classes.FindByID();
                    }
                    break;

                case 4:
                    Console.Clear();
                    isStudentExist = interFace.CheckStudentExist(Classes.Students.Count);
                    if (isStudentExist == 0)
                    {
                        break;
                    }
                    else
                    {
                        Classes.FindStudentsHaveHighestAverageGrade();
                    }
                    break;

                case 5:
                    Console.Clear();
                    isStudentExist = interFace.CheckStudentExist(Classes.Students.Count);
                    if (isStudentExist == 0)
                    {
                        break;
                    }
                    else
                    {
                        Classes.FindFailGrade();
                    }
                    break;

                case 6:
                    Console.Clear();
                    Classes.GetInformationASingleStudent();
                    break;

                case 7:
                    Console.Clear();
                    isStudentExist = interFace.CheckStudentExist(Classes.Students.Count);
                    if (isStudentExist == 0)
                    {
                        break;
                    }
                    else
                    {
                        Classes.CalculateAverages();
                    }
                    break;

                case 8:
                    Console.Clear();
                    isStudentExist = interFace.CheckStudentExist(Classes.Students.Count);
                    if (isStudentExist == 0)
                    {
                        break;
                    }
                    else
                    {
                        Classes.DeleteStudentById();
                    }
                    break;

                case 0: Console.Clear(); Console.Write("DONE"); break;

                default: Console.Clear(); Console.WriteLine("ERROR"); break;
                }
                askToContinue = interFace.CheckToContinue(optionItem);
            } while (optionItem != 0 && askToContinue == 'y');
        }