import junit.framework.TestCase;

/**
 * Test Program 3: Dynamic Programming
 * Created by johnstarich on 8/3/16.
 */
public class Program3Test extends TestCase {
	private int sum(int[] integers) {
		int total = 0;
		for(int i : integers) total += i;
		return total;
	}

	public void testInitialize() throws Exception {
		Program3 program = new Program3();
		int numClasses = 10, maxGrade = 3;
		GradeFunction gradeFunction = new SquareRootGradeFunction(numClasses, maxGrade);
		program.initialize(numClasses, maxGrade, gradeFunction);
		assertEquals(numClasses, program.getNumClasses());
		assertEquals(maxGrade, program.getMaxGrade());
		assertSame(gradeFunction, program.getGradeFunction());
	}

	public void testComputeHours() throws Exception {
		Program3 program = new Program3();
		program.initialize(10, 3, new SquareRootGradeFunction(10, 3));

		assertEquals(40, sum(program.computeHours(40)));
	}

	public void testComputeGrades() throws Exception {
		Program3 program = new Program3();
		program.initialize(10, 3, new SquareRootGradeFunction(10, 3));

		assertEquals(22, sum(program.computeGrades(40)));
	}
}
@@ -721,16 +721,26 @@
 uteHours
+SquareRoot
 () throw
@@ -782,32 +782,60 @@
 new Program3();%0A
+%09%09int n = 10;%0A%09%09int H = 40;%0A
 %09%09program.initia
@@ -831,34 +831,33 @@
 gram.initialize(
-10
+n
 , 3, new SquareR
@@ -865,34 +865,33 @@
 otGradeFunction(
-10
+n
 , 3));%0A%0A%09%09assert
@@ -897,18 +897,17 @@
 tEquals(
-40
+H
 , sum(pr
@@ -925,18 +925,17 @@
 teHours(
-40
+H
 )));%0A%09%7D%0A
@@ -965,16 +965,26 @@
 teGrades
+SquareRoot
 () throw
@@ -1034,16 +1034,44 @@
 ram3();%0A
+%09%09int n = 10;%0A%09%09int H = 40;%0A
 %09%09progra
@@ -1083,18 +1083,17 @@
 tialize(
-10
+n
 , 3, new
@@ -1121,18 +1121,16 @@
 ion(
-10
+n
 , 3));%0A
-%0A
 %09%09as
@@ -1170,17 +1170,214 @@
 eGrades(
-4
+H)));%0A%09%7D%0A%0A%09public void testComputeGradesCustom() %7B%0A%09%09Program3 program = new Program3();%0A%09%09program.initialize(10, 20, new CustomGradeFunction(10, 20));%0A%0A%09%09assertEquals(35, sum(program.computeGrades(2
 0)));%0A%09%7D

Add CustomGradeFunction test