forked from ZXCroon/Wordable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.cpp
executable file
·87 lines (71 loc) · 1.71 KB
/
settings.cpp
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
#include "settings.h"
FormSetting::FormSetting(Env* env) : Interaction(env) {
}
void FormSetting::work() {
cout << " 0. \"Remember or not\"" << endl;
cout << " ";
int num;
for (;;) {
string res = str::readSent(cin);
if (str::isNumber(res)) {
num = str::strToInt(res);
// TODO:...
if (num == 0) {
break;
}
}
cout << " Illegal input! Please re-input:" << endl;
cout << " ";
}
env->basic->setFormStrategy(num);
}
DifficultySetting::DifficultySetting(Env* env): Interaction(env) {
}
void DifficultySetting::work() {
cout << " Difficulty [0-" << DIFFI_NUM - 1
<< "] (input " << -1 << " to turn into random mode, "
<< DIFFI_NUM << " smart mode" << endl;
cout << " ";
int num;
for (;;) {
string res = str::readSent(cin);
if (str::isNumber(res)) {
num = str::strToInt(res);
if (num >= -1 && num <= DIFFI_NUM) {
break;
}
}
cout << " Illegal input! Please re-input:" << endl;
cout << " ";
}
env->basic->setSelectStrategy(num);
}
Settings::Settings(Env* env) : Interaction(env) {
}
void Settings::work() {
for (;;) {
cout << " Difficulty of words to learn [d]" << endl;
cout << " Learning form [f]" << endl;
cout << " Quit [q]" << endl;
cout << endl;
cout << " ";
for (;;) {
string res = str::readSent(cin);
if (res == "q" || res == "Q") {
return;
}
if (res == "d" || res == "D") {
DifficultySetting ds(env);
ds.work();
break;
}
if (res == "f" || res == "F") {
FormSetting fs(env);
fs.work();
break;
}
cout << " Illegal input! Please re-input: ";
cout << " ";
}
}
}