Exemple #1
0
 public void AddTrimesterPerformance(TrimesterPerformance tpf)
 {
     if (tpf == null)
     {
         throw new ArgumentException("Cannot add null trimester to Student Record");
     }
     trimesterPerformanceList.Add(tpf);
 }
Exemple #2
0
        public List <StudentRecord> GenerateStudentRecords(int numToGenerate, StudentRecord courseStructure, List <string> maleNames, List <string> femaleNames, List <string> surNames)
        {
            if ((numToGenerate < 0) || (courseStructure == null) || (maleNames == null) || (femaleNames == null) || (surNames == null))
            {
                throw new ArgumentException("GenerateStudentRecords cannot be run with null or invalid arguments");
            }

            List <StudentRecord> records = new List <StudentRecord>();
            StudentRecord        studRecord;
            string studName = "";
            string idnumber = "";
            Gender studGender;

            for (int i = 0; i < numToGenerate; i++)
            {
                studGender = (Gender)rndFunction.ReturnRandomNumber(0, 2);
                if (studGender == Gender.male)
                {
                    studName = maleNames[rndFunction.ReturnRandomNumber(0, maleNames.Count)];
                }
                else if (studGender == Gender.female)
                {
                    studName = femaleNames[rndFunction.ReturnRandomNumber(0, femaleNames.Count)];
                }
                studName += " " + surNames[rndFunction.ReturnRandomNumber(0, surNames.Count)];

                idnumber   = courseStructure.programme + rndFunction.ReturnRandomNumber(1000, 10000) + i;
                studRecord = new StudentRecord(studName, idnumber, studGender,
                                               studName + DefaultValues.dummyEmailAdd, DefaultValues.dummyContactNumber, courseStructure.programme, courseStructure.creditHrsToGraduate);

                List <UnitGrade>     newGradeList = new List <UnitGrade>();
                UnitGrade            tempGrade;
                TrimesterPerformance tempTrimester;
                int gradeMark;

                foreach (TrimesterPerformance tpf in courseStructure.trimesterPerformanceList)
                {
                    tempTrimester = new TrimesterPerformance(tpf.year, tpf.month, tpf.trimester);
                    newGradeList  = new List <UnitGrade>();
                    foreach (UnitGrade ugrade in tpf.unitGrades)
                    {
                        if (rndFunction.ReturnRandomNumber(0, 5) == 1)
                        {
                            gradeMark = rndFunction.ReturnRandomNumber(0, 51);
                        }
                        else
                        {
                            gradeMark = rndFunction.ReturnRandomNumber(51, 100);
                        }
                        tempGrade = new UnitGrade(ugrade.unitCode, ugrade.unitName, gradeMark);
                        tempGrade.CalculateGrade();
                        newGradeList.Add(tempGrade);
                    }
                    tempTrimester.unitGrades = newGradeList;
                    studRecord.AddTrimesterPerformance(tempTrimester);
                }

                records.Add(studRecord);
            }
            return(records);
        }