From d982cfe8a22ec7eb89186fed875a483a51c3505f Mon Sep 17 00:00:00 2001 From: sowgro Date: Fri, 3 Oct 2025 00:31:02 -0400 Subject: Add code to handle id serialization --- src/main/java/design/model/Golfer.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/main/java/design/model/Golfer.java') diff --git a/src/main/java/design/model/Golfer.java b/src/main/java/design/model/Golfer.java index 8f09067..1a6c7b6 100644 --- a/src/main/java/design/model/Golfer.java +++ b/src/main/java/design/model/Golfer.java @@ -7,15 +7,24 @@ public class Golfer { private String username; private int passwordHash; private String fullName; - private final transient List courses; // might be better to make this like a courseID or something + private final List courses; private final List rounds; + // for deserialization + public Golfer(String username, int passwordHash, String fullName, List courses, List 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() { @@ -61,6 +70,4 @@ public class Golfer { public void addRound(Round round) { rounds.add(round); } - - } -- cgit v1.2.3