diff options
| author | WillemDalton <willemhdalton@gmail.com> | 2025-09-29 18:26:42 -0400 |
|---|---|---|
| committer | WillemDalton <willemhdalton@gmail.com> | 2025-09-29 18:26:42 -0400 |
| commit | c9dbbbf82277036d15a180b0e8609b6dfccb50bd (patch) | |
| tree | 9ee83ef490a54676c2d852a9f995241b6a2bd8f2 /src/model/Round.java | |
| parent | e085ca1bf0b5dd58d8a10d27b009a9f1dd384846 (diff) | |
| download | designproject-design-6-c9dbbbf82277036d15a180b0e8609b6dfccb50bd.tar.gz designproject-design-6-c9dbbbf82277036d15a180b0e8609b6dfccb50bd.tar.bz2 designproject-design-6-c9dbbbf82277036d15a180b0e8609b6dfccb50bd.zip | |
progress on implementing strategy pattern
Diffstat (limited to 'src/model/Round.java')
| -rw-r--r-- | src/model/Round.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/model/Round.java b/src/model/Round.java new file mode 100644 index 0000000..38975da --- /dev/null +++ b/src/model/Round.java @@ -0,0 +1,45 @@ +package design.model; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +public class Round { + private final transient Course course; + private final LocalDateTime dateTime; + private final Hole startingHole; + private final List<Play> plays; + + public Round(Course course, LocalDateTime dateTime, Hole startingHole) { + this.course = course; + this.dateTime = dateTime; + this.startingHole = startingHole; + plays = new ArrayList<>(); + } + + public int getTotalSwings() { + return plays.stream() + .map(Play::getSwingCount) + .reduce(0, Integer::sum); + } + + public Course getCourse() { + return course; + } + + public LocalDateTime getDateTime() { + return dateTime; + } + + public Hole getStartingHole() { + return startingHole; + } + + public Play[] getPlays() { + return plays.toArray(Play[]::new); + } + + public void addPlay(Play play) { + plays.add(play); + } +} |
