static void Main(string[] args) { studentStats[] bestKidsEver = new studentStats[maxStudent]; cohortStats[] bestYearEver = new cohortStats[maxCohort]; int currentCohort = minMatriculation; welcome(); //populates a studentStats array for (int i = 0; i < maxStudent; i++) { bestKidsEver[i] = generateStudent(); } //tests each student in studentStats array for (int i = 0; i < maxStudent; i++) { Console.WriteLine("Testing studentStat class for lucky student #" + i); testStudentStats(bestKidsEver[i]); } Console.WriteLine("Press Enter to Continue..."); pause(); //populates a cohortStats array for (int i = 0; i < maxCohort; i++) { bestYearEver[i] = generateCohort(bestKidsEver, currentCohort); currentCohort++; } currentCohort = minMatriculation; for (int i = 0; i < maxCohort; i++) { Console.WriteLine("Testing cohortStats class for lucky cohort of year: " + currentCohort); if (bestYearEver[i].empty()) { Console.WriteLine("Whoops. I guess no one matriculated that year."); currentCohort++; } else { testCohortStats(bestYearEver[i], currentCohort); currentCohort++; } } goodbye(); Console.WriteLine("Press Enter to Continue..."); pause(); }
static void testCohortStats(cohortStats testCohort, int cohortYear) { studentStats testStudent = generateStudent(); double oldBurden = 0; double newBurden = 0; Console.WriteLine("Data has already been preloaded. Testing if empty: "); if (testCohort.empty()) { Console.WriteLine("True"); } else { Console.WriteLine("False"); } Console.WriteLine("Test for most burden: " + testCohort.findMostBurden()); Console.WriteLine("Test for least burden: " + testCohort.findLeastBurden()); Console.WriteLine("Test for numDeactive: " + testCohort.numDeactive()); oldBurden = testCohort.totalLoans(); Console.WriteLine("Test for total Burden: " + oldBurden); Console.WriteLine("Test for adding student: "); while (testStudent.checkMatriculation(cohortYear) == false) { testStudent = generateStudent(); } newBurden = testCohort.totalLoans(); if (newBurden > oldBurden) { Console.WriteLine("The loan total has increased, meaning add was successful."); } else { Console.WriteLine("The loan total has not increased, meaning add was unsuccessful."); } }
static cohortStats generateCohort(studentStats [] bestStudents, int cohortYr) { cohortStats newCohort = new cohortStats(cohortYr, bestStudents); return(newCohort); }