Newer
Older
import java.util.ArrayList;
import java.util.List;
/**
* A students with results.
*/
public class Student {
private final String firstName;
private final String lastName;
private final List<TeachingUnitResult> results;
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
83
84
85
86
87
88
89
90
91
92
/**
* Constructs a student with the specified first name and last name and no associated results.
*
* @param firstName the first name of the constructed student
* @param lastName the last name of the constructed student
*/
public Student(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.results = new ArrayList<>();
}
/**
* Add a grade associated to a teaching unit to the results of the student.
*
* @param teachingUnitName the name of the teaching unit of the added result
* @param grade the grade of the added result
*/
public void addResult(String teachingUnitName, Grade grade){
}
/**
* Returns a string representation of the student in the format first name last name.
* @return a string representation of the student
*/
@Override
public String toString() {
}
/**
* Returns the grades of the student.
*
* @return the grades of the student
*/
public List<Grade> getGrades(){
}
/**
* Returns the average grade of the student.
*
* @return the average grade of the student
*/
public Grade getAverageGrade() {
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Student student = (Student) o;
if (!firstName.equals(student.firstName)) return false;
return lastName.equals(student.lastName);
}
@Override
public int hashCode() {
int result = firstName.hashCode();
result = 31 * result + lastName.hashCode();
return result;
}
/**
* Print via the standard output the name of the student, all results associated to the students and
* the average grade of the student.
*/
public void printResults(){
}
private void printName() {
}
private void printAverageGrade() {
}
}