Highest Card Modified

Okay I added on the whole deck of cards plus an extra card delt. What I need help with is a cleaner way to code my arguments in determining the highest card. Also after testing one thing that is missing is if there is a high  pair  in any combination of the picture boxes a argument to determine the highest between the high pair  Here is what I have so far.
Private Sub DetermineHighest(ByVal selection As String)
        ' turns the cards face-up, determines whether the  
        ' player selected the highest card, displays the 
        ' number of correct and incorrect selections

        ' counter variables
        Static numCorrect As Integer
        Static numIncorrect As Integer

        Dim card1Value As Integer
        Dim card2Value As Integer
        Dim card3Value As Integer
        Dim card1suitValue As Integer
        Dim card2suitValue As Integer
        Dim card3suitValue As Integer
        Dim highest As String = String.Empty

        ' disable the picture boxes
        card1PictureBox.Enabled = False
        card2PictureBox.Enabled = False
        card3PictureBox.Enabled = False

        ' display cards face-up
        card1PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c0).Front)
        card2PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c1).Front)
        card3PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c2).Front)

        ' convert the face values to numbers
        card1Value = GetNumber(cardDeck.Cards(c0).FaceValue)
        card2Value = GetNumber(cardDeck.Cards(c1).FaceValue)
        card3Value = GetNumber(cardDeck.Cards(c2).FaceValue)

        ' convert the suit values to numbers
        card1suitValue = GetSuit(cardDeck.Cards(c0).Suit)
        card2suitValue = GetSuit(cardDeck.Cards(c1).Suit)
        card2suitValue = GetSuit(cardDeck.Cards(c2).Suit)

        ' determine the highest card
        If card1Value > card2Value AndAlso card1Value > card3Value Then
            highest = "card1"
        ElseIf card2Value > card1Value AndAlso card2Value > card3Value Then
            highest = "card2"
        ElseIf card3Value > card1Value AndAlso card3Value > card2Value Then
            highest = "card3"
        End If
        ' determine the highest card when face value equal
        If card1Value = card2Value AndAlso card1Value = card3Value Then
            If card1suitValue > card2suitValue AndAlso card1suitValue > card3suitValue Then
                highest = "card1"
            ElseIf card2suitValue > card1suitValue AndAlso card2suitValue > card3suitValue Then
                highest = "card2"
            ElseIf card3suitValue > card1suitValue AndAlso card3suitValue > card2suitValue Then
                highest = "card3"
            End If
        End If
        ' determine whether the player’s choice is correct 
        If selection = highest Then
            msgLabel.Text = "Correct!"
            numCorrect = numCorrect + 1
        Else
            msgLabel.Text = "Sorry!"
            numIncorrect = numIncorrect + 1
        End If

        ' display the counters
        correctLabel.Text = numCorrect.ToString
        incorrectLabel.Text = numIncorrect.ToString
    End Sub

Open in new window

timbdesignsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shadow77Commented:
We should have asked earlier whether this is a homework assignment.  That influences the type of assistance we are permitted to offer.  Can you clarify?

What do you mean by "plus an extra card delt"?  Is this necessary?

What do you mean by "cleaner way to code my arguments in determining the highest card"?  Are you referring to the  parameters of your sub or the logic you use to determine the highest card?

0
timbdesignsAuthor Commented:
Yes it is homework. There is now three cards instead of 2 when you click on one of them all the cards are flipped over. If the card you clicked on is the highest (in value) you win. I figured it out. I was over thinking it. I thought I was going to have to use a lot more code then I did. This is what I came up with.
How long does it take before you get comfortable coding vb.net I'm on my finishing up the Visual Basic 2008 Reloaded text book. i learned alot but I am  not close to where I'd like to be. I have a hard time retaining the information from the text, even affter reading it over and over. I'm more of a show me learning type. This class is given online and my instuctor is mostly unavailable at best. So this service you provide is vital in my learning proccess. Thank you.
' determine the highest card
        If card1Value > card2Value AndAlso card1Value > card3Value Then
            highest = "card1"
        ElseIf card2Value > card1Value AndAlso card2Value > card3Value Then
            highest = "card2"
        ElseIf card3Value > card1Value AndAlso card3Value > card2Value Then
            highest = "card3"
        Else
        End If
        ' determine the highest card when face value equal
        If card1suitValue > card2suitValue AndAlso card1suitValue > card3suitValue Then
            highest = "card1"
        ElseIf card2suitValue > card1suitValue AndAlso card2suitValue > card3suitValue Then
            highest = "card2"
        ElseIf card3suitValue > card1suitValue AndAlso card3suitValue > card2suitValue Then
            highest = "card3"
        End If

Open in new window

0
shadow77Commented:
Ok.  Because you're a student, the rules are the site are that we're supposed to help you solve the problem yourself rather than just providing an answer.  That way you get more out of the experience.

To answer your other questions ("how long...", etc), there's no one answer to how long it takes.  It depends on each individual.  I think you will find that your level of comfort starts growing more rapidly as you get more experience, especially if you're young.  As you suggest, the hands on learning is best for most people.  The text is pretty meaningless until you actually try writing code.  Also, don't expect to remember everything; there's too much for most people to remember.  Develop a general understanding (a framework) to which you can attach what you learn and learn how to find what you need to know.  Learn how to find your way around the Help system and get a good reference book like Rod Stephens' Visual Basic 2010 Programmer's Reference (available from Amazon or as an eBook from Wrox); remember that it's a reference manual, not necessarily something you will read cover to cover.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

shadow77Commented:
Regarding the code you provided above, look at it more closely.

Do you always want to execute the second if statement (cardNsuitValue), regardless of the outcome of the first?

If the first if fails all three tests, what are the possible conditions?
0
shadow77Commented:
Here's a reference on ordering suits.  Note that the order depends on the game being played.  I'd probably use the bridge ordering.
http://en.wikipedia.org/wiki/Suit_%28cards%29#Ordering_suits
0
timbdesignsAuthor Commented:
The text gives a refrence of hearts, dimonds, clubs, spades. This I address in the card1suitValue variable One problem I do see is; if the application finds highest = "card 1,2, or 3" I need it to skip the second if decission argument (finding the suit value).
0
shadow77Commented:
Typical orderings of suits include (from highest to lowest):
Bridge (for bidding and scoring) and occasionally poker: spades, hearts, diamonds, clubs
0
shadow77Commented:
>>>One problem I do see is; if the application finds highest = "card 1,2, or 3" I need it to skip the second if decission argument (finding the suit value).

Correct.  You also need to think about how many cases you have when the first if finds no highest card.

Making your current logic work is going to become complex, hard to read, hard to verify, and hard to maintain.  Perhaps you should solve a simpler problem first and then build on that.

Suppose you wanted to create an IsHigher function that compared two card objects and told you whether or not the first was higher than the second.  How would you do that?  In your application, can you assume that one card of a pair will always be higher than the other (when you consider both suit and face)?  Because you are working with objects, add the new function to your Card object.
0
timbdesignsAuthor Commented:
Okay, I've added the face value and the suit values eliminating the need for the second if satements. It seems to work when i tested it.How about this;

I wonder if I could some how combine the GetNumbers, GetSuit and HighCard functions to yet condence more code?


' MainForm
' convert the face values to numbers
        card1Value = GetNumber(cardDeck.Cards(c0).FaceValue)
        card2Value = GetNumber(cardDeck.Cards(c1).FaceValue)
        card3Value = GetNumber(cardDeck.Cards(c2).FaceValue)

        ' convert the suit values to numbers
        card1suitValue = GetSuit(cardDeck.Cards(c0).Suit)
        card2suitValue = GetSuit(cardDeck.Cards(c1).Suit)
        card3suitValue = GetSuit(cardDeck.Cards(c2).Suit)

        ' add the face values and the suit values of dealt cards
        card1suitValue = HighCard(cardDeck.Cards(c0).IsHighest)
        card2suitValue = HighCard(cardDeck.Cards(c1).IsHighest)
        card3suitValue = HighCard(cardDeck.Cards(c2).IsHighest)

        ' determine the highest card
        If card1Value > card2Value AndAlso card1Value > card3Value Then
            highest = "card1"
        ElseIf card2Value > card1Value AndAlso card2Value > card3Value Then
            highest = "card2"
        ElseIf card3Value > card1Value AndAlso card3Value > card2Value Then
            highest = "card3"
        End If

 Private Function HighCard(ByVal isHighest As String) As Integer
        ' add the face value and the suit value
 End Function
'Card.vb
Public Property IsHighest() As String
        Get
            Return _isHighest
        End Get
        Set(ByVal value As String)
            _isHighest = value
        End Set
    End Property

    Public Sub New()
        _front = String.Empty
        _back = String.Empty
        _faceValue = String.Empty
        _suit = String.Empty
        IsHighest = String.Empty
    End Sub

    Public Sub New(ByVal frontFile As String, ByVal backFile As String, _
                   ByVal faceCharacter As String, ByVal faceSuit As String)
        Front = frontFile
        Back = backFile
        FaceValue = faceCharacter
        Suit = faceSuit
        IsHighest = faceCharacter + faceSuit
    End Sub
End Class

Open in new window

0
shadow77Commented:
Good work!

Your latest post contains an interesting idea that can be made to work, but it has some problems.

The MainForm code you sent calculates cardNsuitValue (twice)  but never tests these values.  Maybe you meant to use cardNValue in the lines 13-15, after which lines 2-10 would be unnecessary.

While it's not what I was thinking of doing, your idea of adding face and suit values can be made to work and would simplify your logic considerably (it may even be better than what I was thinking).  However, as you currently define it, it doesn't quite work.

For example, if you used
    spades = 4
    hearts = 3
    diamonds = 2
    clubs = 1
and you had a 9 of clubs and an 8 of spades, which would be higher using your current code?

If you add IsHighest and set its value when you create each card, you no longer need GetNumber and GetSuit.  For the sake of readability, you might want to use a name like CardNumber (instead of IsHighest).  You need to think some more about how to set this value (see the question above); as currently calculated, it will not give you correct values.  Hint:  think about how decimal numbers work.

I don't know what you intended for HighCard, but with your idea of adding face and suit, you no longer need it, nor do yo uneed the function I suggested.

After you get this working, if you would like to consider a couple of additional simplifications, let me know.
0
shadow77Commented:
>>> Hint:  think about how decimal numbers work.

What's another way to write 23 (as a numeric expression; ie, what does 23 mean)?
0
timbdesignsAuthor Commented:
Sorry shadow77, It's been crazy holding down a full-time job and comming to the end of the semester. I'm not any good at math so I'm having a hard time following were your leading.
0
shadow77Commented:
That can squeeze you.

OK, what I was referring to is that 23 is a shorthand for 2*10 + 3, which is significantly different from 2 + 3.  Look at how you calculate IsHighest,, and try comparing the two cards I mentioned using your algorithm.

You're on the right track, but some details need attention so you want to check each of the points in my earlier post.
0
timbdesignsAuthor Commented:
RE: 31128849
Okay, I finally see some of the problems you outlined. I thought fhis code in Card.vb would've taken care of adding the suit value to the face value:
Public Sub New(ByVal frontFile As String, ByVal backFile As String, _
                   ByVal faceCharacter As String, ByVal faceSuit As String)
        Front = frontFile
        Back = backFile
        FaceValue = faceCharacter
        Suit = faceSuit
        IsHighest = faceCharacter + faceSuit
    End Sub
My current code dosen't even add on the suit value do i handle that in Card.vb or in the MainForm.vb?
I tried getting some diffrent combonations of gettig rid of the cardNsuitValue but I kept comming up with a 0 value in my cardNvalues when I tested the application.  I'm not understanding where I deal with my GetNumbers and GetSuit functions if I eliminate these functions. Hope this makes some sense of my confusion.
0
shadow77Commented:
Hi,

OK.  I misread your code.  I now see that _isHighest is a string and that you are forming it by concatenating the face and suit.  I was thinking it was an integer and that you were adding integers.  My fault.  You can keep _isHighest if you wish, but I'm not sure it has any real value.  Passing it to HighCard where it would need to be repeatedly ripped apart, converted and added, would be time-consuming and could be more easily and less frequently done elsewhere.

It would, however, be useful to add a new integer member named _cardNumber (and a property CardNumber) and to calculate it in New by combining GetNumber and GetSuit as described in #31964914.  GetNumber and GetSuit should be moved into your Card class because that's the only place you will need them.  Note that _cardNumber combines two characteristics (_faceValue and _suit) into a single characteristic (itself).

In line 3, you calculate card1Value.
In line 8, you calculate card1suitValue.
In line 13, you calculate card1suitValue again, wiping out what you did in line 8.
In lines 18 and 20, you test card1Value, but you never test card1suitValue, which uses IsHighest (unless there is some code you did not include in your message).

I just point that out so you can see the problems.  In fact, if you introduce _cardNumber, as recommended above, you can replace lines 3-24 (and any further logic in that section that uses card1Value or card1suitValue) with new and simpler code that uses _cardNumber.

If you try using CardNumber, you will see that your code is dramatically simpler (you asked earlier if this were possible).

HighCard is no longer needed.
0
shadow77Commented:
Perhaps I should elaborate a bit on the approach I am suggesting.

The game you are writing presupposes that for any two cards, one will be higher than the other.  If that is true, it should be possible to put the deck in order from lowest to highest.  If you then assign a sequential number to each card, you will have a single characteristic (card number) that can be used to tell which card is higher, making it unnecessary to use two characteristics (suit and face) to tell which card is higher.

If you use face to decide, you have to worry about what to do if two or more cards have the same high face value.  This requires you to use suit as a secondary determinant, and the logic becomes complex.  As you add more cards to a single deal, the logic gets even messier (think what happened when you went from two cards to three; what if you had five cards?).

By using card number, which is sufficient by itself, you avoid all that messy logic.  No two cards will have the same card number.

Also, card number can be calculated once per card when you create the deck.  It never changes.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
timbdesignsAuthor Commented:
Yes! I think I have it! Your last post really helped. I still don't know what your  #31964914 post was about but I added on another attribute (if that is the correct word) to the _cards(51) array assigning it a value, which eliminated the need for the GetNumber and GetSuit functions. I've attached the finished code. Thank you so much! How are you with bingo games? I'll be posting a new thread as soon as I figure out the question. Like where do I start.lol.
DeckOfCards.vb
Option Explicit On
Option Strict On
Option Infer Off

Public Class DeckOfCards
    Private _cards(51) As Card

    Private _nextCard As Integer = 999

    '   Return next two cards, shuffling if necessary
    Public Sub GetThreeCards(ByRef c0 As Integer, ByRef c1 As Integer, ByRef c2 As Integer)
        '   If not two cards left, shuffle
        If _nextCard >= _cards.GetUpperBound(0) Then ShuffleCards()
        c0 = _nextCard
        c1 = _nextCard + 1
        c2 = _nextCard + 2
        _nextCard = _nextCard + 3   ' prepare for next visit
    End Sub

    Public ReadOnly Property Cards(ByVal subscript As Integer) As Card
        Get
            Return _cards(subscript)
        End Get
    End Property

    Public Sub New()
        _cards(0) = New Card("AH.tif", "cardback.tif", "A", "H", "51")
        _cards(1) = New Card("KH.tif", "cardback.tif", "K", "H", "47")
        _cards(2) = New Card("QH.tif", "cardback.tif", "Q", "H", "43")
        _cards(3) = New Card("JH.tif", "cardback.tif", "J", "H", "49")
        _cards(4) = New Card("10H.tif", "cardback.tif", "10", "H", "35")
        _cards(5) = New Card("9H.tif", "cardback.tif", "9", "H", "31")
        _cards(6) = New Card("8H.tif", "cardback.tif", "8", "H", "27")
        _cards(7) = New Card("7H.tif", "cardback.tif", "7", "H", "23")
        _cards(8) = New Card("6H.tif", "cardback.tif", "6", "H", "19")
        _cards(9) = New Card("5H.tif", "cardback.tif", "5", "H", "15")
        _cards(10) = New Card("4H.tif", "cardback.tif", "4", "H", "11")
        _cards(11) = New Card("3H.tif", "cardback.tif", "3", "H", "7")
        _cards(12) = New Card("2H.tif", "cardback.tif", "2", "H", "3")
        _cards(13) = New Card("AD.tif", "cardback.tif", "A", "D", "50")
        _cards(14) = New Card("KD.tif", "cardback.tif", "K", "D", "46")
        _cards(15) = New Card("QD.tif", "cardback.tif", "Q", "D", "42")
        _cards(16) = New Card("JD.tif", "cardback.tif", "J", "D", "38")
        _cards(17) = New Card("10D.tif", "cardback.tif", "10", "D", "34")
        _cards(18) = New Card("9D.tif", "cardback.tif", "9", "D", "30")
        _cards(19) = New Card("8D.tif", "cardback.tif", "8", "D", "26")
        _cards(20) = New Card("7D.tif", "cardback.tif", "7", "D", "22")
        _cards(21) = New Card("6D.tif", "cardback.tif", "6", "D", "18")
        _cards(22) = New Card("5D.tif", "cardback.tif", "5", "D", "14")
        _cards(23) = New Card("4D.tif", "cardback.tif", "4", "D", "10")
        _cards(24) = New Card("3D.tif", "cardback.tif", "3", "D", "6")
        _cards(25) = New Card("2D.tif", "cardback.tif", "2", "D", "2")
        _cards(26) = New Card("AC.tif", "cardback.tif", "A", "C", "49")
        _cards(27) = New Card("KC.tif", "cardback.tif", "K", "C", "45")
        _cards(28) = New Card("QC.tif", "cardback.tif", "Q", "C", "41")
        _cards(29) = New Card("JC.tif", "cardback.tif", "J", "C", "37")
        _cards(30) = New Card("10C.tif", "cardback.tif", "10", "C", "33")
        _cards(31) = New Card("9C.tif", "cardback.tif", "9", "C", "29")
        _cards(32) = New Card("8C.tif", "cardback.tif", "8", "C", "25")
        _cards(33) = New Card("7C.tif", "cardback.tif", "7", "C", "21")
        _cards(34) = New Card("6C.tif", "cardback.tif", "6", "C", "17")
        _cards(35) = New Card("5C.tif", "cardback.tif", "5", "C", "13")
        _cards(36) = New Card("4C.tif", "cardback.tif", "4", "C", "9")
        _cards(37) = New Card("3C.tif", "cardback.tif", "3", "C", "5")
        _cards(38) = New Card("2C.tif", "cardback.tif", "2", "C", "1")
        _cards(39) = New Card("AS.tif", "cardback.tif", "A", "S", "48")
        _cards(40) = New Card("KS.tif", "cardback.tif", "K", "S", "44")
        _cards(41) = New Card("QS.tif", "cardback.tif", "Q", "S", "40")
        _cards(42) = New Card("JS.tif", "cardback.tif", "J", "S", "36")
        _cards(43) = New Card("10S.tif", "cardback.tif", "10", "S", "32")
        _cards(44) = New Card("9S.tif", "cardback.tif", "9", "S", "28")
        _cards(45) = New Card("8S.tif", "cardback.tif", "8", "S", "24")
        _cards(46) = New Card("7S.tif", "cardback.tif", "7", "S", "20")
        _cards(47) = New Card("6S.tif", "cardback.tif", "6", "S", "16")
        _cards(48) = New Card("5S.tif", "cardback.tif", "5", "S", "12")
        _cards(49) = New Card("4S.tif", "cardback.tif", "4", "S", "8")
        _cards(50) = New Card("3S.tif", "cardback.tif", "3", "S", "4")
        _cards(51) = New Card("2S.tif", "cardback.tif", "2", "S", "0")
    End Sub

    Public Sub ShuffleCards()
        Dim randomGenerator As New Random
        Dim randNum1 As Integer
        Dim randNum2 As Integer
        Dim temp As New Card

        For x As Integer = 1 To 25
            randNum1 = randomGenerator.Next(0, 52)
            randNum2 = randomGenerator.Next(0, 52)
            temp = _cards(randNum1)
            _cards(randNum1) = _cards(randNum2)
            _cards(randNum2) = temp
            _nextCard = 0

        Next x
    End Sub
End Class

Card.vb
Option Explicit On
Option Strict On
Option Infer Off

Public Class Card
    Private _front As String
    Private _back As String
    Private _faceValue As String
    Private _suit As String
    Private _cardNumber As String

    Public Property Front() As String
        Get
            Return _front
        End Get
        Set(ByVal value As String)
            _front = value
        End Set
    End Property

    Public Property Back() As String
        Get
            Return _back
        End Get
        Set(ByVal value As String)
            _back = value
        End Set
    End Property

    Public Property FaceValue() As String
        Get
            Return _faceValue
        End Get
        Set(ByVal value As String)
            _faceValue = value
        End Set
    End Property

    Public Property Suit() As String
        Get
            Return _suit
        End Get
        Set(ByVal value As String)
            _suit = value
        End Set
    End Property
    Public Property CardNumber() As String
        Get
            Return _cardNumber
        End Get
        Set(ByVal value As String)
            _cardNumber = value
        End Set
    End Property

    Public Sub New()
        _front = String.Empty
        _back = String.Empty
        _faceValue = String.Empty
        _suit = String.Empty
        _cardNumber = String.Empty
    End Sub

    Public Sub New(ByVal frontFile As String, ByVal backFile As String, _
                   ByVal faceCharacter As String, ByVal faceSuit As String, _
                   ByVal cardValue As String)
        Front = frontFile
        Back = backFile
        FaceValue = faceCharacter
        Suit = faceSuit
        CardNumber = cardValue
    End Sub
    
End Class

MainForm.vb
Option Explicit On
Option Strict On
Option Infer Off

Public Class MainForm

    Private cardDeck As New DeckOfCards
    Private c0 As Integer
    Private c1 As Integer
    Private c2 As Integer


    Private Sub DetermineHighest(ByVal selection As String)
        ' turns the cards face-up, determines whether the  
        ' player selected the highest card, displays the 
        ' number of correct and incorrect selections

        ' counter variables
        Static numCorrect As Integer
        Static numIncorrect As Integer

        Dim card1Value As Integer
        Dim card2Value As Integer
        Dim card3Value As Integer
        Dim highest As String = String.Empty

        ' disable the picture boxes
        card1PictureBox.Enabled = False
        card2PictureBox.Enabled = False
        card3PictureBox.Enabled = False

        ' display cards face-up
        card1PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c0).Front)
        card2PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c1).Front)
        card3PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c2).Front)

        ' convert the face values to numbers
        card1Value = CInt(cardDeck.Cards(c0).CardNumber)
        card2Value = CInt(cardDeck.Cards(c1).CardNumber)
        card3Value = CInt(cardDeck.Cards(c2).CardNumber)

       
        ' determine the highest card
        If card1Value > card2Value AndAlso card1Value > card3Value Then
            highest = "card1"
        ElseIf card2Value > card1Value AndAlso card2Value > card3Value Then
            highest = "card2"
        ElseIf card3Value > card1Value AndAlso card3Value > card2Value Then
            highest = "card3"
        End If
        ' determine whether the player’s choice is correct 
        If selection = highest Then
            msgLabel.Text = "Correct!"
            numCorrect = numCorrect + 1
        Else
            msgLabel.Text = "Sorry!"
            numIncorrect = numIncorrect + 1
        End If

        ' display the counters
        correctLabel.Text = numCorrect.ToString
        incorrectLabel.Text = numIncorrect.ToString
    End Sub
   
    Private Function HighCard(ByVal isHighest As String) As Integer
        ' add the face value and the suit value

    End Function
   
    Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub

    Private Sub dealButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dealButton.Click
        ' shuffles the cards, then displays two cards

        cardDeck.GetThreeCards(c0, c1, c2)


        ' display the back of the first two cards
        card1PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c0).Back)
        card2PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c1).Back)
        card3PictureBox.Image = _
            Image.FromFile(cardDeck.Cards(c1).Back)

        ' enable the picture boxes
        card1PictureBox.Enabled = True
        card2PictureBox.Enabled = True
        card3PictureBox.Enabled = True

        ' clear the msgLabel
        msgLabel.Text = String.Empty
    End Sub

    Private Sub card1PictureBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles card1PictureBox.Click
        Call DetermineHighest("card1")
    End Sub

    Private Sub card2PictureBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles card2PictureBox.Click
        Call DetermineHighest("card2")
    End Sub
    Private Sub card3PictureBox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles card3PictureBox.Click
        Call DetermineHighest("card3")
    End Sub

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Open in new window

0
shadow77Commented:
Great!!  Good work.

You might want to upshift all of the spade numbers by four.  Spades are often considered the highest suit (eg, bridge) and the ace of spades is often considered the highest card.

You asked earlier about becoming a stronger programmer.  One way is to go beyond your assignments, to push to learn more.  This applies while learning, but is not always a good idea when working.  Mnay bosses want you to finish assignments on time and move on; you need to assess each situation.

Regarding this assignment, let me suggest two improvements for you to consider.

Instead of declaring DetermineHighest with a string argument, would it be better to use an integer?  It may not make much difference yet, but the next issue may affect your answer.

When I suggested the GetTwoCards method, I made a common programming error.  I tailored the solution to the specifications at hand.  I didn't think ahead.  Look what happened when you decided to deal three cards instead of two.  You had to change the number of parameters and you even had to change the name of the method.  The change also made the testing logic in DetermineHighest more complicated.  What if you extended the game to four cards, or five?  What if you wanted to let the player choose the number of cards to be dealt so the number wouldn't be known until the game was played?

What simple changes could you make to better handle these concerns?  Can you find a solution that works for any number of cards?  Ignore for now the problem of displaying more cards.
0
timbdesignsAuthor Commented:
shadow77 won't be able to get back to this till after the semester ends in a few weeks. I have my hands full compleating the remaining assesments. Right now I'm working on calling numbers from a BingoNumbers class using alot of what we did here. I posted a new question: Need help with Bingo game. (if your intrested)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.