diff --git a/tp1/Main.java b/tp1/Main.java index 48c980587340fceae55d795e21d60eec84c51690..185824dd55c4a42adf72eae2a8f98e761dda9b8e 100644 --- a/tp1/Main.java +++ b/tp1/Main.java @@ -1,14 +1,4 @@ public class Main { public static void main(String[] args){ - Student student1 = new Student("Arnaud", "Labourel"); - Student student2 = new Student("Paul", "Calcul"); - student1.addResult("Programmation 2", new Grade(20)); - student2.addResult("Programmation 2", new Grade(0)); - student1.addResult("Structures discrètes", new Grade(20)); - student2.addResult("Structures discrètes", new Grade(0)); - Cohort cohort = new Cohort("L2 informatique"); - cohort.addStudent(student1); - cohort.addStudent(student2); - cohort.printStudentsResults(); } } diff --git a/tp1/TestGrade.java b/tp1/TestGrade.java new file mode 100644 index 0000000000000000000000000000000000000000..20c8211dac8f7f2015696362a6d59b3fa9bcac9f --- /dev/null +++ b/tp1/TestGrade.java @@ -0,0 +1,59 @@ +import java.util.ArrayList; + +public class TestGrade { + public static void main(String[] args){ + TestGrade test = new TestGrade(); + if(test.testGetValue() == true) + System.out.println("testGradeValue : correct"); + else + System.out.println("testGradeValue : incorrect"); + + if(test.testToString() == true) + System.out.println("testToString : correct"); + else + System.out.println("testToString : incorrect"); + + if(test.testAverageGrade() == true) + System.out.println("testAverageGrade : correct"); + else + System.out.println("testAverageGrade : incorrect"); + } + + public boolean testGetValue(){ + Grade grade = new Grade(12.5); + double val = grade.getValue(); + if(val == 12.5) + return true; + else + return false; + } + + public boolean testToString(){ + Grade grade = new Grade(13.7); + String gradeString = grade.toString(); + if(gradeString.equals("13.7/20")) + return true; + else + return false; + } + + public boolean testAverageGrade(){ + ArrayList<Grade> list = new ArrayList<Grade>(); + list.add(new Grade(10)); + list.add(new Grade(8)); + list.add(new Grade(12)); + list.add(new Grade(20)); + list.add(new Grade(6)); + Grade average = Grade.averageGrade(list); + if(average.getValue() == 11.2) + return true; + else + return false; + + } + + + + + +}