From c3ea697547950c2e3b48eafeb3a13275be73c5d2 Mon Sep 17 00:00:00 2001 From: jrshi Date: Sun, 16 Nov 2025 15:41:52 -0500 Subject: Cleaning up code --- src/main/java/design/model/ScrambleLeague.java | 9 ++++----- src/main/java/design/model/StrokeLeague.java | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/main/java/design/model') diff --git a/src/main/java/design/model/ScrambleLeague.java b/src/main/java/design/model/ScrambleLeague.java index 64f62f5..1765d81 100644 --- a/src/main/java/design/model/ScrambleLeague.java +++ b/src/main/java/design/model/ScrambleLeague.java @@ -13,8 +13,8 @@ import java.util.Map; @JsonTypeName("scramble") public class ScrambleLeague extends League { - private List participants; - private Map totalTeamScores; + private final List participants; + private final Map totalTeamScores; @JsonCreator private ScrambleLeague(int id, String name, Date registrationDate, Date startDate, Date endDate, Golfer owner, List participants, List schedule) { @@ -31,9 +31,8 @@ public class ScrambleLeague extends League { } public boolean addParticipants(Team t) { - boolean added = participants.add(t); - if(added) totalTeamScores.putIfAbsent(t, 0); - return added; + totalTeamScores.putIfAbsent(t, 0); + return participants.add(t); } public boolean removeParticipants(Team t) { diff --git a/src/main/java/design/model/StrokeLeague.java b/src/main/java/design/model/StrokeLeague.java index 497db20..57ba1aa 100644 --- a/src/main/java/design/model/StrokeLeague.java +++ b/src/main/java/design/model/StrokeLeague.java @@ -13,8 +13,8 @@ import java.util.Map; @JsonTypeName("stroke") public class StrokeLeague extends League { - private List participants; - private Map totalStrokes; + private final List participants; + private final Map totalStrokes; @JsonCreator private StrokeLeague(int id, String name, Date registrationDate, Date startDate, Date endDate, Golfer owner, List participants, List schedule) { @@ -31,9 +31,8 @@ public class StrokeLeague extends League { } public boolean addParticipants(Golfer g) { - boolean added = participants.add(g); - if(added) totalStrokes.putIfAbsent(g, 0); - return added; + totalStrokes.putIfAbsent(g, 0); + return participants.add(g); } public boolean removeParticipants(Golfer g) { -- cgit v1.2.3