-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstrategy.h
117 lines (75 loc) · 1.7 KB
/
strategy.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef STRATEGY_H
#define STRATEGY_H
#include <vector>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include "util.h"
#include "env.h"
class SelectStrategy {
public:
SelectStrategy(Env* env);
string next(int& difficulty);
protected:
virtual int chooseDifficulty() = 0;
Env* env;
int diffi;
};
class FormStrategy {
public:
FormStrategy(Env* env);
virtual string display() = 0;
virtual string reDisplay() = 0;
virtual void rcvResponse(const string& resp) = 0;
void setWord(const string& word);
bool isLegal();
bool isOK();
protected:
Env* env;
string word;
bool legal, ok;
};
// -----------------------------------
/**
Strategies of choosing difficulty of next word.
SmartSelection: select according to level of user.
FixedSelection: select from fixed vocabulary.
RandomSelection: select from all vocabularies at equal probability.
**/
class SmartSelection : public SelectStrategy {
public:
SmartSelection(Env* env);
protected:
int chooseDifficulty();
};
class FixedSelection : public SelectStrategy {
public:
FixedSelection(Env* env, int fixedDiffi);
protected:
int chooseDifficulty();
private:
int fixedDiffi;
};
class RandomSelection : public SelectStrategy {
public:
RandomSelection(Env* env);
protected:
int chooseDifficulty();
};
class RemOrNotForm : public FormStrategy {
public:
RemOrNotForm(Env* env);
string display();
string reDisplay();
void rcvResponse(const string& resp);
};
class SupplementForm : public FormStrategy {
public:
SupplementForm(Env* env);
string display();
string reDisplay();
void rcvResponse(const string& resp);
private:
string processWord();
};
#endif