Example #1
0
            public StudentEnumerator(Student input_s)
            {
                IComparer comparer = new Credit_Exam_Comparer();

                input_s.exam_list.Sort();
                credit_intersect_exam = new ArrayList();
                for (int i = 0; i < input_s.credit_list.Count; i++)
                {
                    //Console.WriteLine("In the loop.");
                    //if (input_s.exam_list.BinarySearch(((Credit)input_s.credit_list[i]).Credit_Name, comparer) > 0)
                    if (input_s.exam_list.BinarySearch((Credit)input_s.credit_list[i], comparer) == 0 ||
                        input_s.exam_list.BinarySearch((Credit)input_s.credit_list[i], comparer) > 0)
                    {
                        credit_intersect_exam.Add(((Credit)input_s.credit_list[i]).Credit_Name);
                        //Console.WriteLine("Added Credit to StudentEnumerator.");
                    }
                }
                this.current = -1;
            }
Example #2
0
        /* Iterates through passed Credits which have corresponding
         * Exam passed with grade > 2
         */
        public IEnumerable <Credit> Passed_Credit_Iterator()
        {
            IComparer comparer = new Credit_Exam_Comparer();

            exam_list.Sort();
            // will return Credit objects only if both credit and exam lists contain smth
            if (credit_list != null && exam_list != null)
            {
                for (int i = 0; i < credit_list.Count; i++)
                {
                    int found_exam_index = exam_list.BinarySearch((Credit)credit_list[i], comparer);
                    if (found_exam_index > 0)
                    {
                        Exam found_exam = (Exam)exam_list[found_exam_index];
                        if (((Credit)credit_list[i]).Credit_Passed &&
                            found_exam.Grade > 2)
                        {
                            yield return((Credit)credit_list[i]);
                        }
                    }
                }
            }
        }
Example #3
0
        /* Iterates through passed Credits which have corresponding
         * Exam passed with grade > 2
         */
        public IEnumerable <Credit> Passed_Credit_Iterator()
        {
            IComparer comparer = new Credit_Exam_Comparer();

            exam_list.Sort();
            // will return Credit objects only if both credit and exam lists contain smth
            if (credit_list != null && exam_list != null)
            {
                for (int i = 0; i < credit_list.Count; i++)
                {
                    int found_exam_index = exam_list.FindIndex(x => x.Exam_Name == credit_list[i].Credit_Name); // new version
                    //int found_exam_index = exam_list.BinarySearch((Credit)credit_list[i], comparer); <- old version
                    if (found_exam_index != -1)
                    {
                        Exam found_exam = exam_list[found_exam_index];
                        if (credit_list[i].Credit_Passed && found_exam.Grade > 2)
                        {
                            yield return(credit_list[i]);
                        }
                    }
                }
            }
        }