-
Notifications
You must be signed in to change notification settings - Fork 0
/
GumballMachine.h
41 lines (37 loc) · 973 Bytes
/
GumballMachine.h
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
32
33
34
35
36
37
38
39
40
41
#ifndef GUMBALL_MACHINE_H
#define GUMBALL_MACHINE_H
#include "State.h"
#include <ostream>
#include <memory>
class NoQuarterState;
class HasQuarterState;
class SoldOutState;
class SoldState;
class GumballMachine {
friend std::ostream& operator<<(std::ostream &, const GumballMachine &);
public:
GumballMachine();
GumballMachine(int);
void insertQuarter();
void ejectQuarter();
void turnCrank();
void releaseBall();
int getCount() const;
void refill(int);
void setState(State *);
State* getState() const;
State* getNoQuarterState() const;
State* getHasQuarterState() const;
State* getSoldOutState() const;
State* getSoldState() const;
State* getWinnerState() const;
private:
std::unique_ptr<State> soldOutState;
std::unique_ptr<State> noQuarterState;
std::unique_ptr<State> hasQuarterState;
std::unique_ptr<State> soldState;
std::unique_ptr<State> winnerState;
State *state;
int count = 0;
};
#endif /* GUMBALL_MACHINE_H */