diff options
| author | Michael Lizzio <mjl2396@rit.edu> | 2025-10-05 03:57:37 -0400 |
|---|---|---|
| committer | Michael Lizzio <mjl2396@rit.edu> | 2025-10-05 03:57:37 -0400 |
| commit | fc8584b1defdbfeaf80ad3e0c7bdb9f53cf2929c (patch) | |
| tree | dd445ae810dab13caacd1f5a6a5e2e8d7588e95a /src/main/java/design/model/holeplay/HolePlayContext.java | |
| parent | 4c485841954cb566d82b2e14a0cddf347a3d8e18 (diff) | |
| download | designproject-design-6-fc8584b1defdbfeaf80ad3e0c7bdb9f53cf2929c.tar.gz designproject-design-6-fc8584b1defdbfeaf80ad3e0c7bdb9f53cf2929c.tar.bz2 designproject-design-6-fc8584b1defdbfeaf80ad3e0c7bdb9f53cf2929c.zip | |
Completed first take of holeplay logic and added empty test files
Diffstat (limited to '')
| -rw-r--r-- | src/main/java/design/model/holeplay/HolePlayContext.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/main/java/design/model/holeplay/HolePlayContext.java b/src/main/java/design/model/holeplay/HolePlayContext.java index e69de29..7445073 100644 --- a/src/main/java/design/model/holeplay/HolePlayContext.java +++ b/src/main/java/design/model/holeplay/HolePlayContext.java @@ -0,0 +1,84 @@ +package design.model.holeplay; + +import design.model.*; +import design.persistence.PersonalDatabase; + +public class HolePlayContext { + private final Golfer golfer; + private final Round round; + private final PersonalDatabase pdb; + + private HoleState state; + private Play currentPlay; + private int strokes; + private int distanceRemainingYds; + + public HolePlayContext(Golfer golfer, Round round, PersonalDatabase pdb) { + this.golfer = golfer; + this.round = round; + this.pdb = pdb; + setState(new SetupState()); + } + + public void setState(HoleState next) { + this.state = next; + next.enter(this); + } + + // API the PTUI/Commands will call: + public void startHole() { + state.handleStart(this); + } + + public void recordShot(Club club, Integer distanceYds) { + state.handleShot(this, club, distanceYds); + } + + public void holeOut() { + state.handleHoleOut(this); + } + + // package-private helpers the states use: + void beginNewPlay(int holeNumber, int par) { + /* create Play, reset counters */ } + + void addSwing(Club club, Integer distanceYds) { + /* add Swing to currentPlay; strokes++; distanceRemainingYds -= distanceYds */ } + + void finalizePlayAndPersist() { + /* round.addPlay(currentPlay); currentPlay=null; pdb.updateGolfer(golfer); */ } + + // getters you’ll want: + public Golfer getGolfer() { + return golfer; + } + + public Round getRound() { + return round; + } + + public Play getCurrentPlay() { + return currentPlay; + } + + public int getStrokes() { + return strokes; + } + + public int getDistanceRemainingYds() { + return distanceRemainingYds; + } + + // setters used internally + void setCurrentPlay(Play p) { + this.currentPlay = p; + } + + void setStrokes(int s) { + this.strokes = s; + } + + void setDistanceRemainingYds(int d) { + this.distanceRemainingYds = d; + } +}
\ No newline at end of file |
