Option Strict On
Option Explicit On
Module Module1
Private coins As Integer = 100
Private r As New Random
Private reels As Dictionary(Of String, Integer)
Sub Main()
Call SetDict()
Console.WriteLine(Instructions)
While coins > 0
Dim response As String = Console.ReadLine
If response.ToLower = "b" Then
Console.WriteLine(Balance)
ElseIf response.ToLower = "d" Then
Console.WriteLine(Instructions)
ElseIf response.ToLower = "p" Then
coins -= 5
Call Pull()
Else
Console.WriteLine("Invalid Input.")
End If
End While
End Sub
Private Sub SetDict()
reels = New Dictionary(Of String, Integer)
reels.Add("Cherry | Cherry | Cherry", 5)
reels.Add("Bar | Bar | Bar", 15)
reels.Add("7 | 7 | 7", 30)
reels.Add("Cherry | Bar | 7", 0)
reels.Add("Cherry | 7 | Bar", 0)
reels.Add("Cherry | Cherry | 7", 2)
reels.Add("Cherry | Cherry | Bar", 2)
reels.Add("7 | Cherry | Bar", 0)
reels.Add("7 | Bar | Cherry", 0)
reels.Add("7 | 7 | Cherry", 0)
reels.Add("7 | 7 | Bar", 0)
reels.Add("Bar | 7 | Cherry", 0)
reels.Add("Bar | Cherry | 7", 0)
reels.Add("Bar | Bar | Cherry", 0)
reels.Add("Bar | Bar | 7", 0)
End Sub
Private Function Balance() As String
Return "Your current coin balance is: " & coins.ToString
End Function
Private Function Instructions() As String
Return String.Format("Instructions:{0}To view your balance type: b{0}To view these instructions type: d{0}To spin the slot machine type: p{0}", Environment.NewLine)
End Function
Private Sub Pull()
Dim spinned_reel As KeyValuePair(Of String, Integer) = reels.ToList()(r.Next(0, reels.Count - 1))
Console.WriteLine(spinned_reel.Key)
coins += spinned_reel.Value
End Sub
End Module