public static void CheckPrerequisitesCorrect(List <StudyUnit> studyunits)
        {
            if (studyunits == null)
            {
                throw new ArgumentException("CheckPrerequisitesCorrect cannot be run with a null argument");
            }


            List <string>     tempString       = new List <string>();
            List <Trimesters> tempTrimesters   = new List <Trimesters>();
            List <Campuses>   tempCampuses     = new List <Campuses>();
            string            exceptionMessage = "";

            for (int i = 0; i < studyunits.Count; i++)
            {
                foreach (string prequnit in studyunits[i].prerequisites)
                {
                    StudyUnit tempstudyunit = new StudyUnit(prequnit, "dummy", tempString, 0, UnitClassification.elective, tempTrimesters, tempCampuses, tempString, 0);
                    if (studyunits.IndexOf(tempstudyunit) == i)
                    {
                        exceptionMessage += "Unit " + studyunits[i].unitCode + " has the same prerequisite\n";
                    }
                    else if (studyunits.IndexOf(tempstudyunit) < 0)
                    {
                        exceptionMessage += "Prerequisite " + prequnit + " for unit " + studyunits[i].unitCode + " does not exist\n";
                    }
                }
            }
            if (exceptionMessage.Length > 1)
            {
                throw new ArgumentException(exceptionMessage);
            }
        }
        public override bool Equals(object obj)
        {
            if ((obj == null))
            {
                return(false);
            }

            if ((obj.GetType() != typeof(StudyUnit)) &&
                (obj.GetType() != typeof(UndergradUnit)) &&
                (obj.GetType() != typeof(PostgradUnit)))
            {
                return(false);
            }

            StudyUnit compUnit = (StudyUnit)obj;

            if (compUnit.unitCode == unitCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void CheckPrerequisites(List <StudyUnit> studyUnits)
        {
            if (studyUnits == null)
            {
                throw new ArgumentException("CheckPrerequisites cannot be run with a null argument");
            }

            List <string>     tempString     = new List <string>();
            List <Trimesters> tempTrimesters = new List <Trimesters>();
            List <Campuses>   tempCampuses   = new List <Campuses>();

            List <UnitGrade> unitGrades, previousGrades;
            StudyUnit        tempUnit, locatedUnit;
            UnitGrade        tempUnitGrade, locatedUnitGrade;
            int           indexLocation;
            List <string> prerequisites;
            bool          foundPrerequisite;
            string        exceptionMessage = "";

            if (trimesterPerformanceList == null)
            {
                return;
            }

            for (int i = 0; i < trimesterPerformanceList.Count; i++)
            {
                unitGrades = trimesterPerformanceList[i].unitGrades;
                for (int j = 0; j < unitGrades.Count; j++)
                {
                    tempUnit = new StudyUnit(unitGrades[j].unitCode, unitGrades[j].unitName, tempString, 0, UnitClassification.elective, tempTrimesters, tempCampuses, tempString, 40);

                    locatedUnit   = studyUnits[studyUnits.IndexOf(tempUnit)];
                    prerequisites = locatedUnit.prerequisites;
                    for (int k = 0; k < locatedUnit.prerequisites.Count; k++)
                    {
                        foundPrerequisite = false;
                        for (int m = i - 1; m >= 0; m--)
                        {
                            previousGrades = trimesterPerformanceList[m].unitGrades;
                            tempUnitGrade  = new UnitGrade(prerequisites[k], " ", 0);
                            indexLocation  = previousGrades.IndexOf(tempUnitGrade);
                            if (indexLocation >= 0)
                            {
                                locatedUnitGrade = previousGrades[indexLocation];
                                if (locatedUnitGrade.mark > locatedUnitGrade.gradingScheme.gradeRanges[0])
                                {
                                    foundPrerequisite = true;
                                    break;
                                }
                            }
                        }
                        if (!foundPrerequisite)
                        {
                            exceptionMessage += "Unit : " + unitGrades[j].unitCode + " has prerequisite " +
                                                locatedUnit.prerequisites[k] + " which has not been fulfilled yet\n";
                        }
                    }
                }
            }
            if (exceptionMessage.Length > 1)
            {
                throw new ArgumentException(exceptionMessage);
            }
        }