Newer
Older
import enumeration.Gender;
import java.util.ArrayList;
import java.util.List;
// final for the ID because it will remain the same for the whole duration of studying or being employed
// PK & FK
private final int id;
private Gender gender;
private String firstName;
private String lastName;
private String placeOfResidence;
private final String birthPlace;
private String officialEmail;
private String privateEmail;
private List<Course> personalCourses = new ArrayList<>();
public UniversityMember(int id, Gender gender, String firstName, String lastName, String placeOfResidence, String birthPlace,
String officialEmail, String privateEmail, List<Course> personalCourses) {
this.id = id;
this.gender = gender;
this.firstName = firstName;
this.lastName = lastName;
this.placeOfResidence = placeOfResidence;
this.birthPlace = birthPlace;
this.officialEmail = officialEmail;
this.privateEmail = privateEmail;
this.personalCourses = personalCourses;
}
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
public Course getCourseForId(int id) {
for (Course course : personalCourses) {
if (course.getId() == id) {
return course;
}
}
return null;
}
public List<Course> getPersonalCourses() {
return personalCourses;
}
public boolean signUpForCourse(Course course) {
if (isSignedUpForCourse(course)) {
return false;
} else {
return personalCourses.add(course);
}
}
public boolean leaveCourse(Course course) {
if (isSignedUpForCourse(course)) {
return personalCourses.remove(course);
} else {
return false;
}
}
public boolean isSignedUpForCourse(Course course) {
return personalCourses.contains(course);
}