Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }