summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/Golfer.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/design/model/Golfer.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/main/java/design/model/Golfer.java b/src/main/java/design/model/Golfer.java
index 48daae8..960568f 100644
--- a/src/main/java/design/model/Golfer.java
+++ b/src/main/java/design/model/Golfer.java
@@ -15,16 +15,18 @@ public class Golfer {
private final List<Round> rounds;
private final List<Club> clubs; // Keep track of golfer's clubs
private int nextClubId;
+ private final List<Invite> invites;
@JsonCreator
private Golfer(String username, int passwordHash, String fullName, List<Course> courses, List<Round> rounds,
- List<Club> clubs) {
+ List<Club> clubs, List<Invite> invites) {
this.username = username;
this.passwordHash = passwordHash;
this.fullName = fullName;
this.courses = courses;
this.rounds = rounds;
this.clubs = clubs;
+ this.invites = invites != null ? invites : new ArrayList<>();
this.nextClubId = this.clubs.stream().mapToInt(Club::getId).max().orElse(0) + 1;
}
@@ -35,6 +37,7 @@ public class Golfer {
this.courses = new ArrayList<>();
this.rounds = new ArrayList<>();
this.clubs = new ArrayList<>();
+ this.invites = new ArrayList<>();
this.nextClubId = 1;
}
@@ -86,8 +89,8 @@ public class Golfer {
rounds.add(round);
}
- public Club addClub(String manufacture, String nickname, Club.ClubType type) {
- Club c = new Club(nextClubId++, manufacture, nickname, type);
+ public Club addClub(Club c) {
+ c.setId(nextClubId++);
clubs.add(c);
return c;
}
@@ -112,4 +115,16 @@ public class Golfer {
public void removeClub(Club c) {
clubs.remove(c);
}
+
+ public boolean addInvite(Invite invite) {
+ return invites.add(invite);
+ }
+
+ public boolean removeInvite(Invite o) {
+ return invites.remove(o);
+ }
+
+ public Invite[] getInvites() {
+ return invites.toArray(Invite[]::new);
+ }
}