forked from fmendozaro/junit-tests
-
Notifications
You must be signed in to change notification settings - Fork 622
Expand file tree
/
Copy pathStudent.java
More file actions
38 lines (30 loc) · 733 Bytes
/
Student.java
File metadata and controls
38 lines (30 loc) · 733 Bytes
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
import java.util.ArrayList;
public class Student {
private long id;
private String name;
private ArrayList<Integer> grades;
public Student(long id, String name){
this.id = id;
this.name = name;
this.grades = new ArrayList<>();
}
public long getId() {
return this.id;
}
public String getName(){
return this.name;
}
public void addGrade(int grade) {
grades.add(grade);
}
public ArrayList<Integer> getGrades() {
return this.grades;
}
public double getGradeAverage() {
double sum = 0;
for (int grade : this.grades) {
sum += grade;
}
return sum / getGrades().size();
}
}