Newer
Older
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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;
/**
* 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){
// TODO : add code
}
/**
* 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() {
// TODO : change code
return null;
}
/**
* Returns the grades of the student.
*
* @return the grades of the student
*/
public List<Grade> getGrades(){
// TODO : change code
return null;
}
/**
* Returns the average grade of the student.
*
* @return the average grade of the student
*/
public Grade averageGrade() {
// TODO : change code
return null;
}
/**
* 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(){
// TODO : add code
}
/**
* Determines whether or not two students are equal. Two instances of Student are equal if the values
* of their {@code firtName} and {@code lastName} member fields are the same.
* @param o an object to be compared with this Student
* @return {@code true} if the object to be compared is an instance of Student and has the same name; {@code false}
* otherwise.
*/
@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);
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
int result = firstName.hashCode();
result = 31 * result + lastName.hashCode();
return result;
}
}