static studentStats generateStudent() { Random debtStatData = new Random(); int newID = debtStatData.Next(); double[] theseLoans = new double[numDegrees]; double[] theseGrants = new double[numDegrees]; int[] theseStartYrs = new int[numDegrees]; int[] theseGrdYrs = new int[numDegrees]; int tempGrants = 0; int tempLoans = 0; //generates a random array of possible grants for (int i = 0; i < numDegrees; i++) { tempGrants = debtStatData.Next(minGrants, maxGrants); theseGrants[i] = (double)tempGrants; } //generates a random array of possible loans for (int i = 0; i < numDegrees; i++) { tempLoans = debtStatData.Next(minLoans, maxLoans); theseLoans[i] = (double)tempLoans; } //generates a random array of possible matriculation years for (int i = 0; i < numDegrees; i++) { theseStartYrs[i] = debtStatData.Next(minMatriculation, maxMatriculation + 1); } //generates a random array of possble grad years for (int i = 0; i < numDegrees; i++) { theseGrdYrs[i] = debtStatData.Next(minGrad, maxGrad); } studentStats newStudent = new studentStats(newID); for (int i = 0; i < numDegrees; i++) { newStudent.addDegree(theseStartYrs[i], theseGrdYrs[i], theseLoans[i], theseGrants[i]); } return(newStudent); }
static void testStudentStats(studentStats testStudent) { Random debtStatData = new Random(); int tempLoans = debtStatData.Next(minLoans, maxLoans); int tempGrants = debtStatData.Next(minGrants, maxGrants); double newGrants = (double)tempGrants; double newLoans = (double)tempLoans; int newMatriculation = debtStatData.Next(minMatriculation, maxMatriculation); int newGradYear = debtStatData.Next(minGrad, maxGrad); double oldBurden = 0; double newBurden = 0; Console.WriteLine("Data has already been preloaded. Testing if empty: "); if (testStudent.isEmpty()) { Console.WriteLine("True"); } else { Console.WriteLine("False"); } Console.WriteLine("Test for most burden: " + testStudent.checkMostBurden()); Console.WriteLine("Test for least burden: " + testStudent.findLeastBurden()); Console.WriteLine("Test for numDeactive: " + testStudent.numDeactive()); Console.WriteLine("Test for default on biggest loan: "); if (testStudent.anyActive()) { testStudent.defaultMostBurden(); } Console.WriteLine("numDeactive is now: " + testStudent.numDeactive()); Console.WriteLine("Previous Biggest Loan now inactive. Biggest Loan is now: " + testStudent.checkMostBurden()); oldBurden = testStudent.totalLoans(); Console.WriteLine("Test for total burden:" + oldBurden); Console.WriteLine("Test for adding degree:"); testStudent.addDegree(newMatriculation, newGradYear, newLoans, newGrants); newBurden = testStudent.totalLoans(); if (oldBurden < newBurden) { Console.WriteLine("The loan total has increased, meaning add was successful."); } else { Console.WriteLine("The loan total has not increased, meaning add was unsuccessful."); } }