-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_meatOfRomajiExercise.go
223 lines (217 loc) · 9.4 KB
/
1_meatOfRomajiExercise.go
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
package main
import (
"fmt"
)
/*
The first of these two functions is passed the user's first guess, and, potentially, it obtains a second guess
.. the second func is passed that second guess, and, potentially, it obtains the third and final guess
Finally, the first func is re-called by the second: the first func is, then, passed the third and final guess ...
... with skipFlag false signifying that the offer to try again is to be replaced with a messages containing the correct
answer, and also a set of hints relating to how one could have known the correct answer.
Since this Exercise (1) expects only Hira guesses, we test for and handle Directives with a simple Alpha test in
... semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt()
*/
func meatOfRomajiExercise(in, selectedExercise string, skipFlag bool) { // - -
if aCard.KeyR == "zu" {
if in == "づ" || in == "ず" {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! ")
fmt.Printf("%s", colorReset)
fmt.Printf("It could have been either ず or づ as they are the same sound: zu\n")
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! ")
if skipFlag == true { // skipFlag is true on first entry, & false when recalled after third failed attempt
// When current func is re-called by secondTry_, with skipFlag false, skip this, and do next ...
fmt.Println("Try again") // ... in other words, this only prints on first pass
fmt.Printf(colorReset)
// Re-prompt, second guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
secondTry_meatOfRomajiExercise(in, selectedExercise)
} else
if skipFlag == false { // skipFlag is true on first entry, & false when recalled after third failed attempt
// If the user guesses incorrectly on third-and-final try, then, and only then, execute the following
fmt.Printf("%s", colorReset)
fmt.Printf(" It was: ")
fmt.Printf("%s", colorCyan)
fmt.Printf("%s", aCard.KeyH)
fmt.Printf("%s", colorReset)
// Display hints in white
fmt.Printf("\n\n%s\n%s\n%s\n", aCard.Hint1h, aCard.Hint2k, aCard.Hint3TT)
fmt.Println("")
}
} // If the user was ^^Right!, then we return to TouchTypingExercises12346_10(SE) (essentially from this line)
} else if
aCard.KeyR == "i" {
if in == "い" {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! ")
fmt.Printf("%s", colorReset)
fmt.Printf(" \"i\" is longer on the left\n")
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! ")
if skipFlag == true { // skipFlag is true on first entry, & false when recalled after third failed attempt
// When current func is re-called by secondTry_, with skipFlag false, skip this, and do next ...
fmt.Println("Try again") // ... in other words, this only prints on first pass
fmt.Printf(colorReset)
// Re-prompt, second guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
secondTry_meatOfRomajiExerciseD(in, selectedExercise)
} else
if skipFlag == false { // skipFlag is true on first entry, & false when recalled after third failed attempt
// If the user guesses incorrectly on third-and-final try, then, and only then, execute the following
fmt.Printf("%s", colorReset)
fmt.Printf(" It was: ")
fmt.Printf("%s", colorCyan)
fmt.Printf("%s", aCard.KeyH)
fmt.Printf("%s", colorReset)
// Display hints in white
fmt.Printf("\n\n%s\n%s\n%s\n", aCard.Hint1h, aCard.Hint2k, aCard.Hint3TT)
fmt.Println("")
}
} // If the user was ^^Right!, then we return to TouchTypingExercises12346_10(SE) (essentially from this line)
} else if
aCard.KeyR == "ri" {
if in == "り" {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! ")
fmt.Printf("%s", colorReset)
fmt.Printf(" \"ri\" is longer on the right\n")
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! ")
if skipFlag == true { // skipFlag is true on first entry, & false when recalled after third failed attempt
// When current func is re-called by secondTry_, with skipFlag false, skip this, and do next ...
fmt.Println("Try again") // ... in other words, this only prints on first pass
fmt.Printf(colorReset)
// Re-prompt, second guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
secondTry_meatOfRomajiExerciseD(in, selectedExercise)
} else
if skipFlag == false { // skipFlag is true on first entry, & false when recalled after third failed attempt
// If the user guesses incorrectly on third-and-final try, then, and only then, execute the following
fmt.Printf("%s", colorReset)
fmt.Printf(" It was: ")
fmt.Printf("%s", colorCyan)
fmt.Printf("%s", aCard.KeyH)
fmt.Printf("%s", colorReset)
// Display hints in white
fmt.Printf("\n\n%s\n%s\n%s\n", aCard.Hint1h, aCard.Hint2k, aCard.Hint3TT)
fmt.Println("")
}
} // If the user was ^^Right!, then we return to TouchTypingExercises12346_10(SE) (essentially from this line)
} else
// Not "zu" or "ri" or "i" [except for two lines, i.e.: if in == "づ" || in == "ず" { ~~> if in == aCardD.KeyH {
// , and the one commented-out line, the remainder of this func is similar to the above] plus one \n
if in == aCard.KeyH {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! \n")
fmt.Printf("%s", colorReset)
// commented-out line
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! ")
if skipFlag == true { // skipFlag is true on first entry, & false when recalled after third failed attempt
// When current func is re-called by secondTry_, with skipFlag false, skip this, and do next ...
fmt.Println("Try again") // ... in other words, this only prints on first pass
fmt.Printf(colorReset)
// Re-prompt, second guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
secondTry_meatOfRomajiExercise(in, selectedExercise)
} else
if skipFlag == false { // skipFlag is true on first entry, & false when recalled after third failed attempt
// If the user guesses incorrectly on third-and-final try, then, and only then, execute the following
fmt.Printf("%s", colorReset)
fmt.Printf(" It was: ")
fmt.Printf("%s", colorCyan)
fmt.Printf("%s", aCard.KeyH)
fmt.Printf("%s", colorReset)
// Display hints in white
fmt.Printf("\n\n%s\n%s\n%s\n", aCard.Hint1h, aCard.Hint2k, aCard.Hint3TT)
fmt.Println("")
}
}
}
/*
.
*/
// Second-Try version of the above func (tests the second guess, and then obtains the third and final one)
func secondTry_meatOfRomajiExercise(in, selectedExercise string) { // - -
if aCard.KeyR == "zu" {
if in == "づ" || in == "ず" {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! ")
fmt.Printf("%s", colorReset)
fmt.Printf("It could have been either ず or づ as they are the same sound: zu\n")
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! Try again\n")
fmt.Printf(colorReset)
// Re-prompt, final guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
meatOfRomajiExercise(in, selectedExercise, false)// Process the third and final guess
}
} else if
aCard.KeyR == "ri" {
if in == "り" {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! ")
fmt.Printf("%s", colorReset)
fmt.Printf(" \"ri\" is longer on the right\n")
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! Try again\n")
fmt.Printf(colorReset)
// Re-prompt, final guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
meatOfRomajiExerciseD(in, selectedExercise, false) // Process the third and final guess
}
} else if
aCard.KeyR == "i" {
if in == "い" {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! ")
fmt.Printf("%s", colorReset)
fmt.Printf(" \"i\" is longer on the left\n")
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! Try again\n")
fmt.Printf(colorReset)
// Re-prompt, final guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
meatOfRomajiExerciseD(in, selectedExercise, false)// Process the third and final guess
}
} else
// Not "zu" or "ri" or "i" [except for two lines, i.e.: if in == "づ" || in == "ず" { ~~> if in == aCardD.KeyH {
// , and the one commented-out line, the remainder of this func is similar to the above] plus one \n
if in == aCard.KeyH {
log_right(aCard.KeyR)
fmt.Printf("%s", colorGreen)
fmt.Printf(" ^^Right! \n")
fmt.Printf("%s", colorReset)
// commented-out line
} else {
log_oops(aCard.KeyR, aCard.KeyH, in)
fmt.Printf("%s", colorRed)
fmt.Printf(" ^^Oops! Try again\n")
fmt.Printf(colorReset)
// Re-prompt, final guess
in = semi_Universal_Prompt_Scan_4_HiraResponse_to_RomajiPrompt(aCard.KeyR, selectedExercise)
meatOfRomajiExercise(in, selectedExercise, false)// Process the third and final guess
}
}