package design.model; import com.fasterxml.jackson.annotation.JsonCreator; import java.util.ArrayList; import java.util.List; public class Play { private int holeNumber; private final List swings; @JsonCreator public Play(int holeNumber, List swings) { this.holeNumber = holeNumber; this.swings = (swings != null) ? swings : new ArrayList<>(); } public Play(int holeNumber) { this.holeNumber = holeNumber; this.swings = new ArrayList<>(); } public int getHoleNumber() { return holeNumber; } public void addSwing(Swing swing) { swings.add(swing); } public Swing[] getSwings() { return swings.toArray(Swing[]::new); } public int getSwingCount() { return swings.size(); } // Returns the sum of all swing distances public int getDistance() { int total = 0; for (Swing s : swings) { total += s.getDistance(); } return total; } }