aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS-TheRevival/TerminalApplications/External/MathQuiz/App_MathQuiz.vb
blob: 58ab882443dede4b851895cb5654e1f6499e7795 (plain) (blame)
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
Module App_MathQuiz
    Public MQ_1stNum As Integer
    Public MQ_2ndNum As Integer
    Public MQ_Operation As String
    Public MQ_ShouldResult As Integer
    Public OperationChooser As Integer

    Public Sub MQ_Start()
        Console.DefaultPrompt = "> "
        ResetLine("MathQuiz for ShiftOS")
        NewLine("Answer basic arithmatical question and you'll get codepoints based on the answer")
        NewLine(Nothing)
        MQ_GiveQuestion()
        Console.CurrentInterpreter = "mathquiz"
        Console.ShouldChange = True
        Console_Interpreters()
    End Sub

    Public Sub MQ_GiveQuestion()
        Try
            Dim RandomNum As New Random
            MQ_1stNum = RandomNum.Next(1, 10)
            MQ_2ndNum = RandomNum.Next(1, 10)
            OperationChooser = RandomNum.Next(1, 5)
            Select Case OperationChooser
                Case 1
                    MQ_Operation = " + "
                    MQ_ShouldResult = MQ_1stNum + MQ_2ndNum
                Case 2
                    While MQ_2ndNum >= MQ_1stNum
                        MQ_2ndNum = RandomNum.Next(1, 10)
                    End While
                    MQ_Operation = " - "
                    MQ_ShouldResult = MQ_1stNum - MQ_2ndNum
                Case 3
                    MQ_Operation = " * "
                    MQ_ShouldResult = MQ_1stNum * MQ_2ndNum
                Case 4
                    While MQ_2ndNum > MQ_1stNum
                        MQ_2ndNum = RandomNum.Next(1, 10)
                    End While
                    MQ_Operation = " / "
                    MQ_ShouldResult = MQ_1stNum / MQ_2ndNum
            End Select
            NewLine("What is " & MQ_1stNum & MQ_Operation & MQ_2ndNum & " ?")
        Catch ex As Exception
            NewLine(ex.Message)
            TerminateApp(Nothing)
        End Try
    End Sub

    Public Sub MQ_CheckAnswer()
        Dim TheAnswer As Integer = command
        If TheAnswer = MQ_ShouldResult Then
            NewLine("You got the right answer! You got " & MQ_ShouldResult & " Codepoint(s)")
            ChangeCP(True, MQ_ShouldResult)
            MQ_GiveQuestion()
        Else
            NewLine("You got the wrong answer! Try again")
            MQ_GiveQuestion()
        End If
    End Sub
End Module