diff options
Diffstat (limited to 'src/main/java/design/model/Match.java')
| -rw-r--r-- | src/main/java/design/model/Match.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/design/model/Match.java b/src/main/java/design/model/Match.java index 4f01c98..525f281 100644 --- a/src/main/java/design/model/Match.java +++ b/src/main/java/design/model/Match.java @@ -5,28 +5,34 @@ import com.fasterxml.jackson.annotation.JsonCreator; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class Match { private final Course course; private final Date dateScheduled; private final LocalDateTime start; + private final LocalDateTime end; private final int holeCount; private final List<Round> rounds; + private final Map<Integer, Round> roundMap = new HashMap<>(); @JsonCreator - private Match(Course course, Date dateScheduled, LocalDateTime start, int holeCount, List<Round> rounds) { + private Match(Course course, Date dateScheduled, LocalDateTime start, LocalDateTime end, int holeCount, List<Round> rounds) { this.course = course; this.dateScheduled = dateScheduled; this.start = start; + this.end = end; this.holeCount = holeCount; this.rounds = rounds; } - public Match(Course course, Date dateScheduled, LocalDateTime start, int holeCount) { + public Match(Course course, Date dateScheduled, LocalDateTime start, LocalDateTime end, int holeCount) { this.course = course; this.dateScheduled = dateScheduled; this.start = start; + this.end = end; this.holeCount = holeCount; this.rounds = new ArrayList<>(); } @@ -54,4 +60,16 @@ public class Match { public Round[] getRounds() { return rounds.toArray(Round[]::new); } + + public boolean checkCompletion() { + return LocalDateTime.now().isAfter(end); + } + + public void addRoundFor(int participantIndex, Round r) { + roundMap.put(participantIndex, r); + } + + public Round getRoundFor(int participantIndex) { + return roundMap.get(participantIndex); + } } |
