diff options
| author | Michael Lizzio <mjl2396@rit.edu> | 2025-10-05 05:29:38 -0400 |
|---|---|---|
| committer | Michael Lizzio <mjl2396@rit.edu> | 2025-10-05 05:29:38 -0400 |
| commit | 40470b1788c28f1c95bba7339dd9819b0e9b95cc (patch) | |
| tree | 2ba839f3fc8fea03612e7f7051176b8d0a059a48 /src/main/java/design/model/Round.java | |
| parent | fc8584b1defdbfeaf80ad3e0c7bdb9f53cf2929c (diff) | |
| download | designproject-design-6-40470b1788c28f1c95bba7339dd9819b0e9b95cc.tar.gz designproject-design-6-40470b1788c28f1c95bba7339dd9819b0e9b95cc.tar.bz2 designproject-design-6-40470b1788c28f1c95bba7339dd9819b0e9b95cc.zip | |
Updated logic and completed holeplay subsystem
Diffstat (limited to 'src/main/java/design/model/Round.java')
| -rw-r--r-- | src/main/java/design/model/Round.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/design/model/Round.java b/src/main/java/design/model/Round.java index 048a21a..bc4914e 100644 --- a/src/main/java/design/model/Round.java +++ b/src/main/java/design/model/Round.java @@ -11,6 +11,7 @@ public class Round { private final LocalDateTime dateTime; private final Hole startingHole; private final List<Play> plays; + private int currentHoleIndex; @JsonCreator private Round(Course course, LocalDateTime dateTime, Hole startingHole, List<Play> plays) { @@ -18,6 +19,9 @@ public class Round { this.dateTime = dateTime; this.startingHole = startingHole; this.plays = plays; + // Allows the golfer to start anywhere on the course. Helps HolePalyContext be + // simpler. + this.currentHoleIndex = Math.max(0, startingHole.getNumber() - 1); } public Round(Course course, LocalDateTime dateTime, Hole startingHole) { @@ -25,6 +29,9 @@ public class Round { this.dateTime = dateTime; this.startingHole = startingHole; plays = new ArrayList<>(); + // Allows the golfer to start anywhere on the course. Helps HolePalyContext be + // simpler. + this.currentHoleIndex = Math.max(0, startingHole.getNumber() - 1); } public int getTotalSwings() { @@ -52,4 +59,14 @@ public class Round { public void addPlay(Play play) { plays.add(play); } + + // Current hole + public Hole getCurrentHole() { + return course.getHoles().get(currentHoleIndex); + } + + // Handles wraparound too + public void nextHole() { + currentHoleIndex = (currentHoleIndex + 1) % course.getHoleCount(); + } } |
