public GradingSchemeResults GetUnitStatsForTrimester(int year, TrimesterMonths triMonths, Trimesters trimester, string unitCodeToLookFor, List <StudentRecord> studentRecords) { if ((unitCodeToLookFor == null) || (studentRecords == null)) { throw new ArgumentException("GetUnitStats cannot be run will null arguments"); } GradingSchemeResults gradeResults = new GradingSchemeResults(); foreach (StudentRecord studRecord in studentRecords) { foreach (TrimesterPerformance tpf in studRecord.trimesterPerformanceList) { if ((tpf.month == triMonths) && (tpf.trimester == trimester) && (tpf.year == year)) { foreach (UnitGrade ugrade in tpf.unitGrades) { if (ugrade.unitCode == unitCodeToLookFor) { gradeResults.AddStudentMark(studRecord.name, studRecord.IDNumber, ugrade.mark); } } break; } } } gradeResults.CalculateOverallResults(); return(gradeResults); }
public TrimesterPerformance(int year, TrimesterMonths month, Trimesters trimester) { this.year = year; this.month = month; this.trimester = trimester; unitGrades = new List <UnitGrade>(); }
public TrimesterPerformance(int year, TrimesterMonths month, Trimesters trimester) { this.year = year; this.month = month; this.trimester = trimester; unitGrades = new List <UnitGrade>(); totalGradePoints = gradePointAverage = cumulativeGradePointAverage = 0; }
public void VerifyTrimesterOrder() { TrimesterMonths curMonth = TrimesterMonths.JAN; Trimesters curTrimester; int curYear = 0; string exceptionMessage = ""; if (trimesterPerformanceList == null) { return; } for (int i = 0; i < trimesterPerformanceList.Count; i++) { if (i == 0) { curMonth = trimesterPerformanceList[i].month; curYear = trimesterPerformanceList[i].year; } else { if (curMonth != trimesterPerformanceList[i].month) { exceptionMessage += "Incorrect month order detected in trimester " + trimesterPerformanceList[i].year + " " + trimesterPerformanceList[i].month + " " + trimesterPerformanceList[i].trimester + " for student ID : " + IDNumber + "\n"; } if (curYear != trimesterPerformanceList[i].year) { exceptionMessage += "Incorrect year order detected in trimester " + trimesterPerformanceList[i].year + " " + trimesterPerformanceList[i].month + " " + trimesterPerformanceList[i].trimester + " for student ID : " + IDNumber + "\n"; } } curTrimester = (Trimesters)i; if (curTrimester != trimesterPerformanceList[i].trimester) { exceptionMessage += "Incorrect trimester order detected in trimester " + trimesterPerformanceList[i].year + " " + trimesterPerformanceList[i].month + " " + trimesterPerformanceList[i].trimester + " for student ID : " + IDNumber + "\n"; } if (curMonth == TrimesterMonths.OCT) { curMonth = TrimesterMonths.JAN; curYear++; } else { curMonth++; } } if (exceptionMessage.Length > 1) { throw new ArgumentException(exceptionMessage); } }
public TrimesterPerformance CreateTrimesterPerformance(List <string> strings) { if (strings == null) { throw new ArgumentException("CreateTrimesterPerformance cannot be run on a null string list"); } char[] delimiters = new char[] { ' ' }; string exceptionMessage = ""; TrimesterMonths month = TrimesterMonths.JAN; Trimesters trimester = Trimesters.Y1T1; int year = 0; IEnumerator ie = strings.GetEnumerator(); ie.MoveNext(); string[] elements = ((string)ie.Current).Trim().Split(delimiters, StringSplitOptions.RemoveEmptyEntries); if (elements.Length != 3) { for (int i = 0; i < elements.Length; i++) { exceptionMessage += elements[i] + " "; } throw new ArgumentException(exceptionMessage + ": " + DefaultValues.ExceptionMessages[12]); } try { year = Convert.ToInt32(elements[0]); } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[13] + "\n"; } try { month = (TrimesterMonths)Enum.Parse(typeof(TrimesterMonths), elements[1].ToUpper()); } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[14] + "\n"; } try { trimester = (Trimesters)Enum.Parse(typeof(Trimesters), elements[2].ToUpper()); } catch (Exception) { exceptionMessage += DefaultValues.ExceptionMessages[15] + "\n"; } if (exceptionMessage.Length > 1) { throw new ArgumentException(elements[0] + " " + elements[1] + " " + elements[2] + " : " + exceptionMessage); } TrimesterPerformance trimesterPerformance = new TrimesterPerformance(year, month, trimester); string curLine; string[] components; UnitGrade ugrade; int mark = 0; while (ie.MoveNext()) { curLine = (string)ie.Current; components = curLine.Trim().Split(':'); if (components.Length != 3) { exceptionMessage += (year + " " + month + " " + trimester) + " : " + DefaultValues.ExceptionMessages[16]; throw new ArgumentException(exceptionMessage); } try { mark = Convert.ToInt32(components[2]); } catch (Exception) { exceptionMessage += components[0].Trim() + " : " + DefaultValues.ExceptionMessages[17]; throw new ArgumentException(exceptionMessage); } ugrade = new UnitGrade(components[0].Trim(), components[1].Trim(), mark); ugrade.gradingScheme = new GradingScheme(); ugrade.CalculateGrade(); trimesterPerformance.AddUnitGrade(ugrade); } return(trimesterPerformance); }