diff options
| author | Tyler Ferrari <69283684+Sowgro@users.noreply.github.com> | 2025-11-16 02:16:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-16 02:16:38 -0500 |
| commit | 73dfd2dd419483c7d1060ef2fb40e328a0209e02 (patch) | |
| tree | 456ed56e629a6324e5993b7ce094705c72e0b922 /src/main/java/design/model/Golfer.java | |
| parent | b5d46c7701716bcb2dd6127aeb97f8fcdb7774fc (diff) | |
| parent | 6ffc6b4cbd9e0c5ce2dc82a7c77f39b3adf849b6 (diff) | |
| download | designproject-design-6-73dfd2dd419483c7d1060ef2fb40e328a0209e02.tar.gz designproject-design-6-73dfd2dd419483c7d1060ef2fb40e328a0209e02.tar.bz2 designproject-design-6-73dfd2dd419483c7d1060ef2fb40e328a0209e02.zip | |
Merge pull request #21 from RIT-SWEN-262/league-model
League model
Diffstat (limited to '')
| -rw-r--r-- | src/main/java/design/model/Golfer.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/main/java/design/model/Golfer.java b/src/main/java/design/model/Golfer.java index 6ea9d32..4fb521e 100644 --- a/src/main/java/design/model/Golfer.java +++ b/src/main/java/design/model/Golfer.java @@ -1,6 +1,7 @@ package design.model; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import java.util.ArrayList; @@ -18,10 +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; @@ -29,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) { @@ -39,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() { @@ -160,5 +169,21 @@ public class Golfer implements Originator { this.clubs.addAll(gm.clubs); 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; + } } |
