BlackJack Game

I'm trying to get the cash counter to add or subtract my winnings.

Page 1 of 1

3 Replies - 1949 Views - Last Post: 16 April 2008 - 05:34 AM Rate Topic: -----

#1 Glidemaster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-April 08

BlackJack Game

Post icon  Posted 14 April 2008 - 09:38 AM

Sub Main()

        Dim Blackjack As String
        Dim PlayerTotal As Integer
        Dim PlayerCard As Integer
        Dim CardCount As Single
        Dim Bet As Integer
        Dim PayOut As Integer
        Dim Money As Integer = 1000
        Dim DealRandom As New Random(System.DateTime.Now.Millisecond)
        Dim Flag As String = "Y"

        Console.WriteLine("Do you want to play Blackjack!!")
        Blackjack = Console.ReadLine()
        Console.WriteLine("How much are you willing to bet?")
        Bet = Console.ReadLine()
        PayOut = PayOut + Bet

        While Bet > Money
            Console.WriteLine("You don't have enough doe, try again money bags!!")
            Console.WriteLine("How much are you willing to bet?")
            Bet = Console.ReadLine()
        End While

        Do While Flag <> "N"
            Select Case PlayerTotal
                Case Is <= 21
                    'Hit
                    PlayerCard = DealRandom.Next(1, 11)
                    PlayerTotal = PlayerTotal + PlayerCard
                    CardCount = CardCount + 1
                    Console.WriteLine("You were dealt a {0}", PlayerCard)
                    Console.WriteLine("Your current total is {0}", PlayerTotal)
                    If PlayerTotal >= 1 Then
                        Console.WriteLine("Do you want a hit?")
                    End If
                    If PlayerTotal = 21 And CardCount = 2 Then
                        Console.WriteLine("Player Blackjacks!    I win!!!    :)/>")
                    End If
                    If PlayerTotal <= 21 And CardCount = 5 Then
                        Console.WriteLine("Player automatically wins!!")
                    End If
                    If PlayerTotal = 21 Then
                        Console.WriteLine("Blackjack!!!    Yah baby, I'm feeling lucky...")
                    End If
                    If PlayerTotal > 21 Then
                        PayOut = (PayOut * 2) - Bet
                        Console.WriteLine("Ahh that's to bad...you busted...you lost {0:c} dollars", PayOut)
                    End If
                    Flag = Console.ReadLine()
                Case Else
                    Flag = "N"
            End Select
        Loop

        Dealer()
        Console.ReadLine()

    End Sub

    Sub Dealer()

        Dim DealerTotal As Integer
        Dim DealRandom As New Random(System.DateTime.Now.Millisecond)
        Dim DealerCard As Integer
        Dim cardcount As Integer
        Dim Flag As String = "N"

        Do While Flag = "N"
            Select Case DealerTotal
                Case Is <= 16
                    'Hit
                    DealerCard = DealRandom.Next(1, 11)
                    DealerTotal = DealerTotal + DealerCard
                    cardcount = cardcount + 1
                    Console.WriteLine("Dealer total is {0}", DealerTotal)

                    If DealerTotal = 21 And cardcount = 2 Then
                        Console.WriteLine("Dealer BlackJack's...I win!!!")
                        Console.ReadLine()
                    End If

                Case Else
                    Flag = "Y"
            End Select

        Loop

        Main()

    End Sub

End Module



EDIT: Code blocks add :)

This post has been edited by PsychoCoder: 14 April 2008 - 09:50 AM


Is This A Good Question/Topic? 0
  • +

Replies To: BlackJack Game

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: BlackJack Game

Posted 14 April 2008 - 01:16 PM

Can you describe the problem that you are having?
Was This Post Helpful? 0
  • +
  • -

#3 Glidemaster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-April 08

Re: BlackJack Game

Posted 15 April 2008 - 05:52 AM

Looking for help on how to write the code for placing a bet and then adding or subtracting the winnings.
Was This Post Helpful? 0
  • +
  • -

#4 JasonMcAuley  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 144
  • Joined: 10-April 08

Re: BlackJack Game

Posted 16 April 2008 - 05:34 AM

Before you play a hand; ask for a bet amount (checking to see if its below their total of course). When a player wins, add the entered bet amount to their total, and when they lose subtract it. I don't know a whole lot about blackjack payouts; so just apply whatever payout rules apply to the logic and thats it.

Seems fairly simple to me; unless you had something else in mind?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1