package design.model; import com.fasterxml.jackson.annotation.JsonCreator; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; public class Round { private final Course course; private final LocalDateTime dateTime; private final Hole startingHole; private final List plays; @JsonCreator private Round(Course course, LocalDateTime dateTime, Hole startingHole, List plays) { this.course = course; this.dateTime = dateTime; this.startingHole = startingHole; this.plays = 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); } }