-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.go
More file actions
50 lines (40 loc) · 989 Bytes
/
app.go
File metadata and controls
50 lines (40 loc) · 989 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
package main
func runApplication() error {
printer, err := NewLogPrinter()
if err != nil {
return err
}
profile, err := ReadProfile(printer)
if err != nil {
return err
}
stat := NewStat()
answersDistribution := NewDistribution[int]()
generator, err := NewOperandGenerator(profile)
if err != nil {
return err
}
answerReader := NewConsoleAnswerReader()
stat.PrintStartMessage(printer)
for i := 0; i < profile.ExamplesCount; i++ {
example, err := generator.GenerateExample(profile, answersDistribution)
if err != nil {
return err
}
answer, err := answerReader.Read(printer, i+1, example)
if err != nil {
return err
}
stat.AddAnswer(answer)
if profile.ShowCorrectAnswerAfter == AfterEach {
printer.Println(answer.GetAnalysis())
}
}
printer.Println("===============")
if profile.ShowCorrectAnswerAfter == AfterAll {
stat.PrintAllAnswers(printer)
}
stat.PrintStatistics(printer)
printer.Println("===============\n")
return nil
}