OOP Project Template

This commit is contained in:
OOP Project Team
2019-02-14 01:11:37 +01:00
commit d001b5ac26
12 changed files with 520 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package grade;
import java.util.stream.IntStream;
public class ProjectGrade {
/**
* Returns a grade depending on if you used git and the project compiles.
* @param usedGit true if git was used
* @param compiles true if the project compiled
* @param grade grade calculated from the rubric
* @return grade
*/
public static double calculateGrade(boolean usedGit, boolean compiles, double grade) {
if (!usedGit || !compiles) {
return 1.0;
}
return grade;
}
public static boolean usesLambda() {
return IntStream.of(0, 2, 4, 6, 8, 10).map(i -> i * i)
.allMatch(i -> (i + 1) % 2 == 1);
}
/**
* Tells you when the ta is happy.
* @param bringCake true if you brought cake
* @return happyness of the TA
*/
public static boolean taIsHappy(boolean bringCake) {
return bringCake;
}
}

View File

@@ -0,0 +1,48 @@
package grade;
import org.junit.Assert;
import org.junit.Test;
public class ProjectGradeTest {
private static final double DELTA = 0.001;
@Test
public void getGoodGradeIfCorrect() {
double grade = ProjectGrade.calculateGrade(true, true, 7.5);
Assert.assertEquals(7.5, grade, DELTA);
}
@Test
public void getBadGradeIfNotCompiles() {
double grade = ProjectGrade.calculateGrade(true, false, 7.5);
Assert.assertEquals(1, grade, DELTA);
}
@Test
public void getBadGradeIfNotUsedGit() {
double grade = ProjectGrade.calculateGrade(false, true, 7.5);
Assert.assertEquals(1, grade, DELTA);
}
@Test
public void testTaIsNotHappy() {
Assert.assertFalse(ProjectGrade.taIsHappy(false));
}
@Test
public void testTaIsHappy() {
Assert.assertTrue(ProjectGrade.taIsHappy(true));
}
@Test
public void testIsUsingLambda() {
Assert.assertTrue(ProjectGrade.usesLambda());
}
}