Skip to content
Snippets Groups Projects
Commit e93f9d5a authored by MSAYIF Bassem's avatar MSAYIF Bassem
Browse files

Updated Grade Class

Implémentation des méthodes toString, getValue et averageGrade.
parent b9bfe82c
Branches
No related tags found
Loading
......@@ -28,6 +28,7 @@ public class Grade {
*/
public double getValue() {
return value;
}
/**
......@@ -36,6 +37,7 @@ public class Grade {
*/
@Override
public String toString() {
return getValue() + "/20";
}
/**
......@@ -46,6 +48,15 @@ public class Grade {
* @return a grade corresponding to the mean of grade in {@code grades}
*/
public static Grade averageGrade(List<Grade> grades){
double sum = 0;
double total = 0;
if(!grades.isEmpty()) {
for (Grade grade : grades) {
sum += grade.value;
}
total = sum / grades.size();
}
return new Grade(total);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment