summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/design/controller/userinput/menus/LeageMenu.java4
-rw-r--r--src/main/java/design/model/ScrambleLeague.java9
-rw-r--r--src/main/java/design/model/StrokeLeague.java9
3 files changed, 9 insertions, 13 deletions
diff --git a/src/main/java/design/controller/userinput/menus/LeageMenu.java b/src/main/java/design/controller/userinput/menus/LeageMenu.java
index 4e2f079..fb03d52 100644
--- a/src/main/java/design/controller/userinput/menus/LeageMenu.java
+++ b/src/main/java/design/controller/userinput/menus/LeageMenu.java
@@ -24,9 +24,7 @@ public class LeageMenu extends Menu {
@Override
public List<MenuOption> getMenuOptions() {
List<MenuOption> options = new ArrayList<>();
- options.add(new MenuOption("statistics...", () -> {
- new LeagueStatsMenu(league).present();
- }));
+ options.add(new MenuOption("statistics...", () -> new LeagueStatsMenu(league).present()));
options.add(new MenuOption("log round...", () -> {
var holePlay = new HolePlayMenu();
holePlay.present();
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<Team> participants;
- private Map<Team, Integer> totalTeamScores;
+ private final List<Team> participants;
+ private final Map<Team, Integer> totalTeamScores;
@JsonCreator
private ScrambleLeague(int id, String name, Date registrationDate, Date startDate, Date endDate, Golfer owner, List<Team> participants, List<Match> 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<Golfer> participants;
- private Map<Golfer, Integer> totalStrokes;
+ private final List<Golfer> participants;
+ private final Map<Golfer, Integer> totalStrokes;
@JsonCreator
private StrokeLeague(int id, String name, Date registrationDate, Date startDate, Date endDate, Golfer owner, List<Golfer> participants, List<Match> 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) {