forked from Harshil1823/Learning-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourseGrade.java
More file actions
63 lines (54 loc) · 1.39 KB
/
CourseGrade.java
File metadata and controls
63 lines (54 loc) · 1.39 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
import java.util.ArrayList;
/**
* @author JavaDoc
* Represents grade for course.
*/
public class CourseGrade {
private Course course;
private String userID;
private double totalGrade;
private ArrayList<Module> modules;
/**
* Constructor to initialize CourseGrade.
* @param course Type Course of course.
* @param userID Type String of userID.
*/
public CourseGrade(Course course, double totalGrade, String userID) {
this.course = course;
this.userID = userID;
this.totalGrade = getTotalGrade();
this.modules = course.getModules();
}
/**
* Returns course.
* @return Type Course of course.
*/
public Course getCourse() {
return this.course;
}
/**
* Returns user id.
* @return String of user id.
*/
public String getUserID() {
return this.userID;
}
/**
* Calculates total grade and returns it.
* @return double of course grade.
*/
public double getTotalGrade() {
double total = 0;
for(int i = 0; i < modules.size(); i++)
total += modules.get(i).getModuleGrade();
total = total / modules.size();
return total;
}
/**
* Returns module grades.
* @return Type ArrayList<ModuleGrade> of module grades.
*/
public ArrayList<Module> getModules() {
return this.modules;
}
}