diff options
| author | Tyler Ferrari <69283684+Sowgro@users.noreply.github.com> | 2025-10-08 15:29:14 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-08 15:29:14 -0400 |
| commit | bf6b01e5005618e6ccdfb4217311a8f94dd5a0dd (patch) | |
| tree | 9d1a8af5e7829d0357ecfe8d0d9d51eb4c929091 /src/main/java/design/model/Golfer.java | |
| parent | 701aba30fe05f65ab0e027f9d9aac0928d814560 (diff) | |
| parent | a20f2f027981ce9c7677b969be24c962c0029907 (diff) | |
| download | designproject-design-6-bf6b01e5005618e6ccdfb4217311a8f94dd5a0dd.tar.gz designproject-design-6-bf6b01e5005618e6ccdfb4217311a8f94dd5a0dd.tar.bz2 designproject-design-6-bf6b01e5005618e6ccdfb4217311a8f94dd5a0dd.zip | |
Merge pull request #9 from RIT-SWEN-262/lizzio-SelectClub
Lizzio select club
Diffstat (limited to 'src/main/java/design/model/Golfer.java')
| -rw-r--r-- | src/main/java/design/model/Golfer.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/design/model/Golfer.java b/src/main/java/design/model/Golfer.java index 19d6ac6..d34073f 100644 --- a/src/main/java/design/model/Golfer.java +++ b/src/main/java/design/model/Golfer.java @@ -11,15 +11,19 @@ public class Golfer { private String fullName; private final List<Course> courses; private final List<Round> rounds; - private final List<Club> clubs = new ArrayList<>(); // Keep track of golfer's clubs + private final List<Club> clubs; // Keep track of golfer's clubs + private int nextClubId = 1; @JsonCreator - private Golfer(String username, int passwordHash, String fullName, List<Course> courses, List<Round> rounds) { + private Golfer(String username, int passwordHash, String fullName, List<Course> courses, List<Round> rounds, + List<Club> clubs) { this.username = username; this.passwordHash = passwordHash; this.fullName = fullName; this.courses = courses; this.rounds = rounds; + this.clubs = clubs; + this.nextClubId = this.clubs.stream().mapToInt(Club::getId).max().orElse(0) + 1; } public Golfer(String fullName, String username, String password) { @@ -28,6 +32,8 @@ public class Golfer { this.passwordHash = password.hashCode(); this.courses = new ArrayList<>(); this.rounds = new ArrayList<>(); + this.clubs = new ArrayList<>(); + this.nextClubId = 1; } public String getUsername() { @@ -74,12 +80,17 @@ public class Golfer { rounds.add(round); } - // Helpers dealing with clubs - public void addClub(Club c) { + public Club addClub(String manufacture, String nickname, Club.ClubType type) { + Club c = new Club(nextClubId++, manufacture, nickname, type); clubs.add(c); + return c; } public boolean hasClub(Club c) { return clubs.contains(c); } + + public Club[] getClubs() { + return clubs.toArray(Club[]::new); + } } |
