|
-
Dec 28th, 2010, 10:34 PM
#1
Thread Starter
Junior Member
hi lo card game
I have a couple quick questions with the program that I am doing. This program is a hi\lo program and here are my remaining issues...
1. When I click the high or low button in my program it does not make changes to my token (I want the default tokens to be 100 and added 100 to the text property of my textbox so want to make sure I did that right)
2. In my program it only shows 13 possibilities but want to have the ability to add more
3. I also would like to change 1 to ace, 11 to jack, 12 to queen, and 13 to king and would like to get some assistance with that as well
I think I have everything else taken care of but this is the code I have...
Code:
Public Class Form1
Private randomgen As New Random
Private cards As Integer
Private cardpicked As Object
Private clicked As Integer = 1
Private used1, used2, used3, used4, used5, used6, used7, used8, used9, used10 As Integer
Private myList As New List(Of Integer)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For index As Integer = 1 To 13
myList.Add(index)
Next
ShuffleCards(1000)
End Sub
Private Sub ShuffleCards(ByVal NumberOfTimes As Integer)
Dim listIndex As Integer
Dim output As String = ""
Dim currentCard As Integer
Try
For index As Integer = 1 To NumberOfTimes
listIndex = randomgen.Next(1, 14) - 1
'Get a currentCard
currentCard = myList.Item(listIndex)
'Remove it at a RANDOM position.
myList.RemoveAt(listIndex)
'Add it back to the list at the end of the list.
myList.Add(currentCard)
Next
For cardNumber As Integer = 1 To 13
output &= myList(cardNumber - 1) & ControlChars.NewLine
Next
Catch
End Try
MessageBox.Show("Card Order is now" & ControlChars.NewLine & output)
End Sub
Private Sub PickCard()
Dim cardNumber As Integer
If myList.Count > 0 Then
cardNumber = myList.Item(0)
myList.RemoveAt(0)
ElseIf myList.Count = 0 Then
MessageBox.Show("No more cards left sorry!!")
Exit Sub
End If
MessageBox.Show("CardNumber is now " & cardNumber)
clicked = clicked + 1
End Sub
Private Sub cardCheckButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cardCheckButton.Click
PickCard()
End Sub
Private Sub highButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles highButton.Click
' Dim cardNumber As Integer
'If cardNumber >> cardpicked Then
'tokensTextBox = 100 + 10
'ElseIf cardNumber << cardpicked Then
'tokensTextBox = 100 - 10
'End If
End Sub
Private Sub tokensTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tokensTextBox.TextChanged
'START WITH 100 TOKENS
End Sub
Private Sub lowButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lowButton.Click
'Dim cardNumber As Integer
'If cardNumber >> cardpicked Then
' tokensTextBox = tokensTextBox - 10
'ElseIf cardNumber << cardpicked Then
' tokensTextBox = 100 + 10
End Sub
Private Sub quitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quitButton.Click
Me.Close()
End Sub
End Class
-
Dec 28th, 2010, 11:39 PM
#2
Thread Starter
Junior Member
Re: hi lo card game
made some changes but still not working if anyone can take a look
Code:
Public Class Form1
Private randomgen As New Random
Private cards As Integer
Private cardpicked As Object
Private clicked As Integer = 1
Private used1, used2, used3, used4, used5, used6, used7, used8, used9, used10 As Integer
Private myList As New List(Of Integer)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For index As Integer = 1 To 13
myList.Add(index)
Next
ShuffleCards(1000)
End Sub
Private Sub ShuffleCards(ByVal NumberOfTimes As Integer)
Dim listIndex As Integer
Dim output As String = ""
Dim currentCard As Integer
Try
For index As Integer = 1 To NumberOfTimes
listIndex = randomgen.Next(1, 14) - 1
'Get a currentCard
currentCard = myList.Item(listIndex)
'Remove it at a RANDOM position.
myList.RemoveAt(listIndex)
'Add it back to the list at the end of the list.
myList.Add(currentCard)
Next
For cardNumber As Integer = 1 To 13
output &= myList(cardNumber - 1) & ControlChars.NewLine
Next
Catch
End Try
MessageBox.Show("Card Order is now" & ControlChars.NewLine & output)
End Sub
Private Sub PickCard()
Dim cardNumber As Integer
If myList.Count > 0 Then
cardNumber = myList.Item(0)
myList.RemoveAt(0)
ElseIf myList.Count = 0 Then
MessageBox.Show("No more cards left sorry!!")
Exit Sub
End If
'BEFORE OPENING THE PROGRAM THIS SHOWS THE ORDER OF THE CARDS
MessageBox.Show("CardNumber is now " & cardNumber)
clicked = clicked + 1
End Sub
Private Sub cardCheckButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cardCheckButton.Click
PickCard()
End Sub
Private Sub highButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles highButton.Click
Dim cardNumber As Integer
If cardNumber > cardpicked Then
tokensTextBox.Text = tokensTextBox.Text + tokensToBetTextBox.Text
ElseIf cardNumber < cardpicked Then
tokensTextBox.Text = tokensTextBox.Text - tokensToBetTextBox.Text
End If
End Sub
Private Sub tokensTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tokensTextBox.TextChanged
'START WITH 100 TOKENS
End Sub
Private Sub lowButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lowButton.Click
Dim cardNumber As Integer
If cardNumber > cardpicked Then
tokensTextBox.Text = tokensTextBox.Text - tokensToBetTextBox.Text
ElseIf cardNumber < cardpicked Then
tokensTextBox.Text = tokensTextBox.Text + tokensToBetTextBox.Text
End If
End Sub
Private Sub quitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quitButton.Click
Me.Close()
End Sub
Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub tokensToBetTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tokensToBetTextBox.TextChanged
If Val(tokensToBetTextBox.Text) < 10 Then
tokensToBetTextBox.Text = Val(tokensToBetTextBox.Text)
End If
End Sub
End Class
-
Dec 29th, 2010, 07:53 AM
#3
Re: hi lo card game
What are the rules of Hi / Lo ? How do you play?
-
Dec 29th, 2010, 08:09 AM
#4
Thread Starter
Junior Member
Re: hi lo card game
here are the instructions(I do not need images of the cards)
Higher or lower is played by shuffling the cards, and then dealing one card from the deck. The player then chooses whether the next card drawn from the deck
will be higher or lower than the first card drawn. It the player guesses correctly, they win. Otherwise they lose.
Your game should have the facilities to keep score in some manner – tokens tend to work well.
You should add embellishments to your program to make it attractive to potential players.
One decision you must make is when to deal the cards. The odds change based upon whether you deal prior to each game, or if you use the same deck for several hands of the game.
-
Dec 29th, 2010, 08:10 AM
#5
Thread Starter
Junior Member
Re: hi lo card game
here are the instructions(I do not need images of the cards)
Higher or lower is played by shuffling the cards, and then dealing one card from the deck. The player then chooses whether the next card drawn from the deck
will be higher or lower than the first card drawn. It the player guesses correctly, they win. Otherwise they lose.
Your game should have the facilities to keep score in some manner – tokens tend to work well.
You should add embellishments to your program to make it attractive to potential players.
One decision you must make is when to deal the cards. The odds change based upon whether you deal prior to each game, or if you use the same deck for several hands of the game.
bkruep is online now Rate this post
Add to bkruep's Reputation Report Post Edit/Delete Message
-
Dec 29th, 2010, 08:50 AM
#6
Re: hi lo card game
Card ideas
Code:
Class tCard
Public _rank As Ranks
Public _suit As Suits
End Class
Dim deck As List(Of tCard)
Dim PRNG As New Random
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
'shuffle new deck
deck = New List(Of tCard)
For Each s As Suits In [Enum].GetValues(GetType(Suits))
For Each r As Ranks In [Enum].GetValues(GetType(Ranks))
Dim foo As New tCard
foo._rank = r
foo._suit = s
deck.Add(foo)
Next
Next
deck = deck.OrderBy(Function(rn) PRNG.Next).ToList
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
Dim c1 As tCard = GetCardFromDeck()
Dim c2 As tCard = GetCardFromDeck()
If c1._rank > c2._rank Then
Stop
ElseIf c1._rank < c2._rank Then
Stop
Else
Stop
End If
End Sub
Function GetCardFromDeck() As tCard
If deck.Count = 0 Then
'no more cards
Throw New IndexOutOfRangeException("Deck Empty")
End If
Dim idx As Integer = PRNG.Next(deck.Count)
Dim aCard As New tCard
aCard = deck(idx)
deck.RemoveAt(idx)
Return aCard
End Function
Public Enum Suits
Spades
Hearts
Diamonds
Clubs
End Enum
Public Enum Ranks
Two
Three
Four
Five
Six
Seven
Eight
Nine
Ten
Jack
Queen
King
Ace
End Enum
Public Structure deckConstants
Shared NumberOfSuits As Integer = [Enum].GetNames(GetType(Suits)).Length
Shared NumberOfRanks As Integer = [Enum].GetNames(GetType(Ranks)).Length
End Structure
-
Dec 29th, 2010, 09:04 AM
#7
Thread Starter
Junior Member
Re: hi lo card game
So are you suggesting I disregard my entire code and use all the changes you made from the code you just posted(fyi that response did not mean any disrespect but over a forum and not face to face it may sound like it but thank you for your help)
-
Dec 29th, 2010, 09:15 AM
#8
Re: hi lo card game
I was just showing you a slightly different approach. You seem to have the basics down. If you disregard what I posted it will not bother me in the least. You won't be the first, you won't be the last.
-
Dec 29th, 2010, 09:21 AM
#9
Thread Starter
Junior Member
Re: hi lo card game
haha sounds good Ill plug in your code when I get home tonight and take a look. I do not see form1 but I am guessing it all goes in there
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|