fork download
  1. Imports System
  2.  
  3. Module Module1
  4. Const QUESTION_TYPE_ADDITION As Integer = 0
  5. Const QUESTION_TYPE_SUBTRACTION As Integer = 1
  6. Const QUESTION_TYPE_MULTIPLICATION As Integer = 2
  7. Const QUESTION_TYPE_DIVISION As Integer = 3
  8.  
  9. Public Class Teacher
  10. Private Dim RandomGenerator As Random
  11. Private Dim Question As String
  12. Private Dim Answer As Integer
  13. Private Dim Score As Integer
  14.  
  15. Public Sub GenerateQuestion()
  16. Dim QuestionType As Integer = RandomGenerator.Next(0, 3)
  17. Dim FirstNumber As Integer = RandomGenerator.Next(1, 100)
  18. Dim SecondNumber As Integer = RandomGenerator.Next(1, 100)
  19.  
  20. Select Case QuestionType
  21. Case QUESTION_TYPE_ADDITION
  22. Question = FirstNumber & " + " & SecondNumber & " = ?"
  23. Answer = FirstNumber + SecondNumber
  24.  
  25. Case QUESTION_TYPE_SUBTRACTION
  26.  
  27. Case QUESTION_TYPE_MULTIPLICATION
  28.  
  29. Case QUESTION_TYPE_DIVISION
  30.  
  31. Case Else
  32. Console.WriteLine("Something went wrong. ;-;")
  33. End Select
  34. End Sub
  35.  
  36. Public Sub AskQuestion()
  37. Console.Clear()
  38. Console.WriteLine(Question)
  39.  
  40. Dim Entry As Integer = Console.Read()
  41. If Entry = Answer Then
  42. Console.WriteLine("Correct!")
  43. Score += 1
  44. Else
  45. Score -= 1
  46. End If
  47. End Sub
  48.  
  49. Public Function GetScore() As Integer
  50. Return Score
  51. End Function
  52. End Class
  53.  
  54. Public Class Program
  55. Public Shared Sub Main
  56. Dim teacher As Teacher = New Teacher()
  57. Dim index As Integer = 1
  58.  
  59. While index <> 10
  60. teacher.GenerateQuestion()
  61. teacher.AskQuestion()
  62.  
  63. index += 1
  64. End While
  65.  
  66. Console.WriteLine("Your score is " & teacher.GetScore())
  67. End Sub
  68. End Class
  69. End Module
  70.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 3.8 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

vbnc : error VBNC30420: Could not find a 'Sub Main' in 'prog'.
There were 1 errors and 0 warnings.
Compilation took 00:00:01.0132200
stdout
Standard output is empty