Skip to content
Snippets Groups Projects
Commit 4141bdb4 authored by Alexis Nasr's avatar Alexis Nasr
Browse files

ajout d'un classe pour tester Grade

parent 212247b7
No related branches found
No related tags found
No related merge requests found
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();
}
}
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment