summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/Golfer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/design/model/Golfer.java')
-rw-r--r--src/main/java/design/model/Golfer.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/main/java/design/model/Golfer.java b/src/main/java/design/model/Golfer.java
index 8f09067..19d6ac6 100644
--- a/src/main/java/design/model/Golfer.java
+++ b/src/main/java/design/model/Golfer.java
@@ -1,5 +1,7 @@
package design.model;
+import com.fasterxml.jackson.annotation.JsonCreator;
+
import java.util.ArrayList;
import java.util.List;
@@ -7,15 +9,25 @@ public class Golfer {
private String username;
private int passwordHash;
private String fullName;
- private final transient List<Course> courses; // might be better to make this like a courseID or something
+ private final List<Course> courses;
private final List<Round> rounds;
+ private final List<Club> clubs = new ArrayList<>(); // Keep track of golfer's clubs
+
+ @JsonCreator
+ private Golfer(String username, int passwordHash, String fullName, List<Course> courses, List<Round> rounds) {
+ this.username = username;
+ this.passwordHash = passwordHash;
+ this.fullName = fullName;
+ this.courses = courses;
+ this.rounds = rounds;
+ }
public Golfer(String fullName, String username, String password) {
- this.courses = new ArrayList<>();
- this.rounds = new ArrayList<>();
this.fullName = fullName;
this.username = username;
this.passwordHash = password.hashCode();
+ this.courses = new ArrayList<>();
+ this.rounds = new ArrayList<>();
}
public String getUsername() {
@@ -62,5 +74,12 @@ public class Golfer {
rounds.add(round);
}
+ // Helpers dealing with clubs
+ public void addClub(Club c) {
+ clubs.add(c);
+ }
+ public boolean hasClub(Club c) {
+ return clubs.contains(c);
+ }
}