PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[VB.Net] Console Application Slots-VBForums
Results 1 to 3 of 3

Thread: [VB.Net] Console Application Slots

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,540

    [VB.Net] Console Application Slots

    A fun console app to play the slots. This is the source code.

    Notes:
    This uses LINQ so you must have the .Net framework 3.5 or higher installed.

    Source Code:
    vb.net Code:
    1. Option Strict On
    2. Option Explicit On
    3. Module Module1
    4.     Private coins As Integer = 100
    5.     Private r As New Random
    6.     Private reels As Dictionary(Of String, Integer)
    7.  
    8.     Sub Main()
    9.         Call SetDict()
    10.         Console.WriteLine(Instructions)
    11.  
    12.         While coins > 0
    13.             Dim response As String = Console.ReadLine
    14.             If response.ToLower = "b" Then
    15.                 Console.WriteLine(Balance)
    16.             ElseIf response.ToLower = "d" Then
    17.                 Console.WriteLine(Instructions)
    18.             ElseIf response.ToLower = "p" Then
    19.                 coins -= 5
    20.                 Call Pull()
    21.             Else
    22.                 Console.WriteLine("Invalid Input.")
    23.             End If
    24.         End While
    25.     End Sub
    26.  
    27.     Private Sub SetDict()
    28.         reels = New Dictionary(Of String, Integer)
    29.         reels.Add("Cherry | Cherry | Cherry", 5)
    30.         reels.Add("Bar | Bar | Bar", 15)
    31.         reels.Add("7 | 7 | 7", 30)
    32.         reels.Add("Cherry | Bar | 7", 0)
    33.         reels.Add("Cherry | 7 | Bar", 0)
    34.         reels.Add("Cherry | Cherry | 7", 2)
    35.         reels.Add("Cherry | Cherry | Bar", 2)
    36.         reels.Add("7 | Cherry | Bar", 0)
    37.         reels.Add("7 | Bar | Cherry", 0)
    38.         reels.Add("7 | 7 | Cherry", 0)
    39.         reels.Add("7 | 7 | Bar", 0)
    40.         reels.Add("Bar | 7 | Cherry", 0)
    41.         reels.Add("Bar | Cherry | 7", 0)
    42.         reels.Add("Bar | Bar | Cherry", 0)
    43.         reels.Add("Bar | Bar | 7", 0)
    44.     End Sub
    45.  
    46.     Private Function Balance() As String
    47.         Return "Your current coin balance is: " & coins.ToString
    48.     End Function
    49.  
    50.     Private Function Instructions() As String
    51.         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)
    52.     End Function
    53.  
    54.     Private Sub Pull()
    55.         Dim spinned_reel As KeyValuePair(Of String, Integer) = reels.ToList()(r.Next(0, reels.Count - 1))
    56.         Console.WriteLine(spinned_reel.Key)
    57.         coins += spinned_reel.Value
    58.     End Sub
    59.  
    60. End Module
    Last edited by dday9; Oct 17th, 2013 at 09:40 AM.

  2. #2

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,540

    Re: [VB.Net] Console Application Slots

    -Duplicate Post-
    Last edited by dday9; Aug 12th, 2013 at 03:49 PM.

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,540

    Re: [VB.Net] Console Application Slots

    A quick update. I fixed everything in the slots. Now it's a perfect console application slots. As always I'm up for suggestions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width