-
Notifications
You must be signed in to change notification settings - Fork 0
/
JoyCode.py
74 lines (58 loc) · 1.88 KB
/
JoyCode.py
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
from sys import platform as sys_pf
if sys_pf == 'darwin':
import matplotlib
matplotlib.use("TkAgg")
import sys
sys.path.append('.')
import Helpers.IO as io
import random
import emoji
import settings
from Grade_K.TestCases import TestCases
import Helpers.Control as CTR
import GUIs.gui as GUI
def chooseGrade():
gradeList = [str(i) for i in range(1,9)]
gradeList = ['k'] + gradeList
while 1:
io.printTTS('Please choose the Grade of the student:')
io.printTTS(" k for Kindergarten")
io.printTTS(" [1-8] for Grade 1 to 8")
grade = io.readChar()
if grade in gradeList:
return grade
else:
io.printTTS("Only Grade {} is currently supported".format(gradeList))
continue
"""
This is the main function of the project
"""
def main():
if settings.guiflag:
GUI.KidsMath().mainloop()
sys.exit(1)
print(">>>> Welcome to KidsMath, Enjoy! <<<<")
grade = chooseGrade()
k = TestCases(grade)
while not k:
io.printTTS("Selected Grade {} has not been implemented yet".format(k))
grade = chooseGrade()
k = TestCases(grade)
object_methods = [method_name for method_name in dir(k)
if callable(getattr(k, method_name))]
object_methods = CTR.RemoveSysMethods(object_methods)
io.printTTS("There are totally {} test cases implemented".format(len(object_methods)))
io.printTTS("Please specify how many tests you want try:")
testcnt = io.readInt()
RandomMethodList = []
for i in range(testcnt):
secure_random = random.SystemRandom()
m = secure_random.choice(object_methods)
RandomMethodList.append(m)
object_methods.remove(m)
print(RandomMethodList)
# recursively call all the test cases
for name in RandomMethodList:
getattr(k, name)()
if __name__ == '__main__':
main()