From 4141bdb45ee92bf8a3113bd4f106aa2ef1970363 Mon Sep 17 00:00:00 2001
From: Alexis Nasr <alexis.nasr@lif.univ-mrs.fr>
Date: Wed, 9 Sep 2020 10:07:40 +0200
Subject: [PATCH] ajout d'un classe pour tester Grade

---
 tp1/Main.java      | 10 --------
 tp1/TestGrade.java | 59 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 10 deletions(-)
 create mode 100644 tp1/TestGrade.java

diff --git a/tp1/Main.java b/tp1/Main.java
index 48c9805..185824d 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 0000000..20c8211
--- /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;
+		
+    }
+    
+
+    
+    
+    
+}
-- 
GitLab