diff options
Diffstat (limited to '')
| -rw-r--r-- | src/main/java/design/model/Golfer.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/java/design/model/Golfer.java b/src/main/java/design/model/Golfer.java index 84f7396..4fb521e 100644 --- a/src/main/java/design/model/Golfer.java +++ b/src/main/java/design/model/Golfer.java @@ -19,12 +19,14 @@ public class Golfer implements Originator { private final List<Round> rounds; private final List<Club> clubs; // Keep track of golfer's clubs private int nextClubId; + private final List<Invite> invites; + private Team joinedTeam; @JsonCreator private Golfer(String username, int passwordHash, String fullName, List<Course> courses, List<Round> rounds, - List<Club> clubs) { + List<Club> clubs, List<Invite> invites, Team joinedTeam) { this.username = username; this.passwordHash = passwordHash; this.fullName = fullName; @@ -32,6 +34,8 @@ public class Golfer implements Originator { this.rounds = rounds; this.clubs = clubs; this.nextClubId = this.clubs.stream().mapToInt(Club::getId).max().orElse(0) + 1; + this.invites = invites; + this.joinedTeam = joinedTeam; } public Golfer(String fullName, String username, String password) { @@ -42,6 +46,8 @@ public class Golfer implements Originator { this.rounds = new ArrayList<>(); this.clubs = new ArrayList<>(); this.nextClubId = 1; + this.invites = new ArrayList<>(); + this.joinedTeam = null; } public String getUsername() { @@ -164,4 +170,20 @@ public class Golfer implements Originator { this.nextClubId = gm.nextClubId; } + + public boolean joinTeam(Team team){ + for(Invite invite : invites){ + if(invite.getTeam().equals(team)){ + this.joinedTeam = team; + team.addMember(this); + invites.remove(invite); + return true; + } + } + return false; + } + + public Team getTeam(){ + return joinedTeam; + } } |
