1
0

sample.vb.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. Imports System
  2. Imports System.Collections.Generic
  3. Module Module1
  4. Sub Main()
  5. Dim a As New M8Ball
  6. Do While True
  7. Dim q As String = ""
  8. Console.Write("ask me about the future... ")
  9. q = Console.ReadLine()
  10. If q.Trim <> "" Then
  11. Console.WriteLine("the answer is... {0}", a.getAnswer(q))
  12. Else
  13. Exit Do
  14. End If
  15. Loop
  16. End Sub
  17. End Module
  18. Class M8Ball
  19. Public Answers As System.Collections.Generic.Dictionary(Of Integer, String)
  20. Public Sub New()
  21. Answers = New System.Collections.Generic.Dictionary(Of Integer, String)
  22. Answers.Add(0, "It is certain")
  23. Answers.Add(1, "It is decidedly so")
  24. Answers.Add(2, "Without a doubt")
  25. Answers.Add(3, "Yes, definitely")
  26. Answers.Add(4, "You may rely on ")
  27. Answers.Add(5, "As I see it, yes")
  28. Answers.Add(6, "Most likely")
  29. Answers.Add(7, "Outlook good")
  30. Answers.Add(8, "Signs point to yes")
  31. Answers.Add(9, "Yes")
  32. Answers.Add(10, "Reply hazy, try again")
  33. Answers.Add(11, "Ask again later")
  34. Answers.Add(12, "Better not tell you now")
  35. Answers.Add(13, "Cannot predict now")
  36. Answers.Add(14, "Concentrate and ask again")
  37. Answers.Add(15, "Don't count on it")
  38. Answers.Add(16, "My reply is no")
  39. Answers.Add(17, "My sources say no")
  40. Answers.Add(18, "Outlook not so")
  41. Answers.Add(19, "Very doubtful")
  42. End Sub
  43. Public Function getAnswer(theQuestion As String) As String
  44. Dim r As New Random
  45. Return Answers(r.Next(0, 19))
  46. End Function
  47. End Class