summaryrefslogtreecommitdiff
path: root/src/main/java/design/model/holeplay/PlayState.java
blob: e41af6b0e4419427de6124cb09d13e48f71bbe9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package design.model.holeplay;

import design.model.Club;

public class PlayState implements HoleState {
    @Override
    public void enter(HolePlayContext ctx) {
        /* no-op */ }

    @Override
    public void handleStart(HolePlayContext ctx) {
        throw new IllegalStateException("Hole already started.");
    }

    @Override
    public void handleShot(HolePlayContext ctx, Club club, Integer distanceYds) {
        ctx.addSwing(club, distanceYds);
        // remain in PlayState
    }

    @Override
    public void handleHoleOut(HolePlayContext ctx) {
        ctx.finalizePlayAndPersist();
        ctx.setState(new HoleCompleteState());
    }

    @Override
    public String name() {
        return "PlayState";
    }
}