COMP2396
Loading...
Searching...
No Matches
Guest.java
Go to the documentation of this file.
1package tutorial4.part3.q3;
2
3import java.util.ArrayList;
4
5final class Attendance {
6 private final Event event;
7 private final String venue;
8 public Attendance(Event event, String venue) {
9 this.event = event;
10 this.venue = venue;
11 }
12 public boolean isIdentical(Attendance attendance) {
13 return this.event == attendance.event && this.venue.equals(attendance.venue);
14 }
15}
16
17public class Guest {
18 private final String name;
19
20 private final ArrayList<Attendance> joinedEvents = new ArrayList<>();
21 public Guest(String name) {
22 this.name = name;
23 }
24 public void joinEvent(Event event, String venue) {
25 joinedEvents.add(new Attendance(event, venue));
26 }
27 private ArrayList<Attendance> getJoinedEvents() {
28 return joinedEvents;
29 }
30 public boolean hasCloseContactWith(Guest guest) {
31 for (Attendance attendance : joinedEvents) {
32 for (Attendance guestAttendance : guest.getJoinedEvents()) {
33 if (attendance.isIdentical(guestAttendance)) {
34 return true;
35 }
36 }
37 }
38 return false;
39 }
40
41 public String getName() {
42 return name;
43 }
44}
void joinEvent(Event event, String venue)
Definition Guest.java:24
Guest(String name)
Definition Guest.java:21
final ArrayList< Attendance > joinedEvents
Definition Guest.java:20
ArrayList< Attendance > getJoinedEvents()
Definition Guest.java:27
boolean hasCloseContactWith(Guest guest)
Definition Guest.java:30
final String name
Definition Guest.java:18