我在本节中遇到多个错误,试图找出计算机获胜、用户获胜或平局。任何人都可以帮助编辑我的代码吗?我刚刚达到了我的能力的尽头。我猜我必须使用对象?但我一直在编辑我的代码,从这里开始只会变得更糟。如果有人可以帮助我,我将非常感激!
' Card shuffling and dealing application.
Public Class DeckOfCardsTest
Dim userwin As Integer
Dim compwin As Integer
Dim ties As Integer
Private deck As New DeckOfCards() ' create the deck of cards
' shuffle the deck when user clicks the Shuffle Button
Private Sub shuffleButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles shuffleButton.Click
deck.Shuffle() ' shuffles the deck
card1PictureBox.Image = Nothing ' clear image
card2PictureBox.Image = Nothing ' clear image
dealButton.Enabled = True ' allow user to click the Deal Button
MessageBox.Show("Deck is shuffled")
End Sub ' shuffleButton_Click
Private Sub dealButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles dealButton.Click
End Sub ' dealButton_Click
' return an image for the Card argument
Private Function GetCardImage(ByVal card As Card) As Image
If card IsNot Nothing Then
' retrieve specific card image from resources
Dim pictureResource = My.Resources.ResourceManager.GetObject(
card.ToString().Replace(" ", ""))
Return CType(pictureResource, Image) ' return Image
Else
dealButton.Enabled = False ' disable the Deal Button
Return Nothing ' no more cards
End If
End Function ' GetCardImage
End Class ' DeckOfCardsTest