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
53 lines (45 loc) · 1.06 KB
/
Student.java
File metadata and controls
53 lines (45 loc) · 1.06 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
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<>();
}
// returns the student's id
public long getId(){
return id;
}
// returns the student's name
public String getName(){
return name;
}
// adds the given grade to the grades list
public void addGrade(int grade){
grades.add(grade);
}
// returns the list of grades
public ArrayList<Integer> getGrades(){
return this.grades;
}
// returns the average of the students grades
public double getGradeAverage(){
double sum = 0;
double numOfGrades = grades.size();
for(double grade : grades){
sum += grade;
}
return sum/numOfGrades;
}
// // update grade()
// public int updateGrade(){
//
// }
//
// // delete grade()
// public int deleteGrade(){
//
// }
}