Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the Lucky Seven game to present the user with a video poker hand (5 card)

ID: 3645257 • Letter: M

Question

Modify the Lucky Seven game to present the user with a video poker hand (5 card). While you do not have to present graphics for the 5 cards, you may wish to change the main screen graphic to something of your own design. For the cards, each card can be any available from a standard deck of cards. Once a card is used, it cannot be used again in that hand (example: you draw the Jack of Hearts; you cannot draw that same card again). When all 5 cards are shown on screen, allow the user to discard and draw new cards once (up to all 5 cards at a time, but only allow them to change the cards once). Inform the user of their result in a dialog box (example: 3 of a kind or 2 pairs, etc.). After the user clears the result, allow the user to draw a hand again or exit the program.

Explanation / Answer

Public Class Deck Private cards As Hand 'The cards currently in the deck. Private rand As Random 'Used to generate random numbers. Public ReadOnly Property Count() As Integer Get Return Me.cards.Count End Get End Property Public Sub New() Me.cards = New Hand 'Create a full deck with no Jokers. For Each suit As Suit In [Enum].GetValues(GetType(Suit)) If suit suit.None Then For Each face As Face In [Enum].GetValues(GetType(Face)) If face face.None Then Me.cards.Add(New Card(face, suit)) End If Next face End If Next suit Me.rand = New Random End Sub Public Sub Shuffle() Dim shuffledCards As New Hand While Me.cards.Count > 0 Dim index As Integer = Me.rand.Next(0, Me.cards.Count) 'Add a card at random to the new deck from the existing deck. shuffledCards.Add(Me.cards(index)) 'Remove the chosen card from the existing deck. Me.cards.RemoveAt(index) End While Me.cards = shuffledCards End Sub Public Sub Cut(ByVal upperCount As Integer) 'Move the first upperCount cards to the bottom. For i As Integer = 1 To upperCount Me.cards.Add(Me.cards(0)) Me.cards.RemoveAt(0) Next i End Sub 'Returns the next card without removing it from the deck. Public Function PeekNextCard() As Card Return Me.cards(0) End Function 'Returns the next card and removes it from the deck. Public Function GetNextCard() As Card Dim nextCard As Card = Me.cards(0) Me.cards.RemoveAt(0) Return nextCard End Function 'Returns the specified number of hands, each with the specified number of cards. Public Function Deal(ByVal handCount As Integer, ByVal cardCount As Integer) As Hand() Dim hands(handCount - 1) As Hand For i As Integer = 1 To cardCount Step 1 For Each hand As Hand In hands hand.Add(Me.GetNextCard) Next hand Next i Return hands End Function End Class
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote