forked from yogykwan/design-patterns-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrategy.h
More file actions
54 lines (42 loc) · 851 Bytes
/
strategy.h
File metadata and controls
54 lines (42 loc) · 851 Bytes
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
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// Created by Jennica on 2017/1/2.
//
#ifndef DESIGN_PATTERNS_STRATEGY_H
#define DESIGN_PATTERNS_STRATEGY_H
#include <string>
class CashSuper {
public:
virtual ~CashSuper() {}
virtual double AcceptCash(double) = 0;
};
class CashNormal: public CashSuper {
public:
double AcceptCash(double);
};
class CashRebate: public CashSuper {
public:
CashRebate() {}
CashRebate(double);
double AcceptCash(double);
private:
double money_rebate_;
};
class CashReturn: public CashSuper {
public:
CashReturn() {}
CashReturn(double, double);
double AcceptCash(double);
private:
double money_condition_;
double money_return_;
};
class CashContext {
public:
CashContext() {}
CashContext(std::string, std::string);
~CashContext();
double GetResult(double);
private:
CashSuper *cash_;
};
#endif //DESIGN_PATTERNS_STRATEGY_H