-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourse.java
More file actions
82 lines (69 loc) · 2.58 KB
/
Course.java
File metadata and controls
82 lines (69 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package data;
import java.util.*;
public class Course extends AbstractTeachingUnit {
public Course(String courseName, String courseID, int credit) {
super(courseName, courseID, credit);
}
public double getMoyenne(Student student) {
double note = -1;
if(!hasStudent(student)) {return -2;}
if(hasStudent(student) && student.getNotesMap().get(this.getID()) >= 0) {
note = student.getNotesMap().get(this.getID());
}
return note;
}
public double getNoteMoyenne(List<Student> studentList) {
int nbNotes = 0;
double sommeNotes = 0;
for(Student student : studentList) {
if(hasStudent(student) && student.getNotesMap().get(this.getID()) >= 0) {
double noteStudent = student.getNotesMap().get(this.getID());
sommeNotes += noteStudent;
nbNotes += 1;
}
}
return (sommeNotes / nbNotes);
}
public boolean hasStudent(Student student) {
return !(student.getNotesMap().get(this.getID()) == null);
}
public double getNoteMax(List<Student> studentList) {
double max = 0;
for(Student student : studentList) {
if(hasStudent(student) && student.getNotesMap().get(this.getID()) > max) {
max = student.getNotesMap().get(this.getID());
}
}
return max;
}
public double getNoteMin(List<Student> studentList) {
double max = 20;
for(Student student : studentList) {
if(hasStudent(student) && student.getNotesMap().get(this.getID()) < max && student.getNotesMap().get(this.getID()) >= 0) {
max = student.getNotesMap().get(this.getID());
}
}
return max;
}
public double getEcartType(List<Student> studentList) {
double moyenne = this.getNoteMoyenne(studentList);
double nombreNote = 0;
double acc = 0;
for (Student student : studentList)
{
if(hasStudent(student) && student.getNotesMap().get(this.getID()) >= 0) {
double note = student.getNotesMap().get(this.getID());
nombreNote += 1;
double squrDiffToMean = Math.pow(note - moyenne, 2);
acc += squrDiffToMean;
}
}
double meanOfDiffs = acc / nombreNote;
return Math.sqrt(meanOfDiffs);
}
public String toString()
{
return String.format(" Cours ID : %s, courseName: %s, credits : %d" ,
this.getID(), this.getName(), this.getCredit());
}
}