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

Using Microsoft Visual Studio Coding in Visual Basic. I understand the concept.

ID: 3700881 • Letter: U

Question

Using Microsoft Visual Studio Coding in Visual Basic. I understand the concept. I just cannot for the life of me figure out how to write the code to deal two unique cards and continue that through the entire deck while tracking points.

Professor's Assignment (Not in book) Deal two cards from an array..one each to two players and determine who is the winner. No duplicates allowed, since that will get you, at the minimum, banned from the casino Name of one gambler should be entered by the user, the other (the computer) should be Cassy Windsall. Keep track of the player win, and provide comments of encouragement throughout the tournament When user decides to quit, the overall tournament winner should be announced

Explanation / Answer

Option Strict On

Option Explicit On

Option Infer Off

Option Compare Binary

Public Class Form1

Const Joker As Integer = 15

Const players As Integer = 4

Const cardsPerPlayer As Integer = 7

Dim hands(players, cardsPerPlayer) As Card

Structure Card

Dim Rank As Integer

Dim Suit As Integer

Dim RandomPosition As Integer

End Structure

Structure Player

Dim Computer As String

Dim Opposite As String

Dim Winner As String

End Structure

Dim Deck(0 To 53) As Card

'initialize deck

Dim ran As New Random

Sub New()

' This call is required by the Windows Form Designer.

' Add any initialization after the InitializeComponent() call.

InitializeComponent()

CreateDeck()

End Sub

Sub CreateDeck()

Dim cardIndex As Integer = 0

Dim Rank As Integer

Dim Suit As Integer

For Rank = 2 To 14

For Suit = 1 To 4

Deck(cardIndex).Rank = Rank

Deck(cardIndex).Suit = Suit

Deck(cardIndex).RandomPosition = ran.Next

cardIndex = cardIndex + 1

Next

Next

'Create two jokers

Deck(52).Rank = Joker

Deck(52).Suit = 0

Deck(52).RandomPosition = ran.Next

Deck(53).Rank = Joker

Deck(53).Suit = 0

Deck(53).RandomPosition = ran.Next

End Sub

Function StringCard(ByVal oneCard As Card) As String

Dim output As String = ""

Select Case oneCard.Rank

Case 2 : output = "Two"

Case 3 : output = "Three"

Case 4 : output = "Four"

Case 5 : output = "Five"

Case 6 : output = "Six"

Case 7 : output = "Seven"

Case 8 : output = "Eight"

Case 9 : output = "Nine"

Case 10 : output = "Ten"

Case 11 : output = "Jack"

Case 12 : output = "Queen"

Case 13 : output = "King"

Case 14 : output = "Ace"

Case Joker : output = "Joker"

End Select

If oneCard.Rank <> Joker Then

Select Case oneCard.Suit

Case 1 : output = output & " of clubs"

Case 2 : output = output & " of hearts"

Case 3 : output = output & " of spades"

Case 4 : output = output & " of diamonds"

End Select

End If

Return output

End Function

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim playerCount As Integer = 0

Dim cardCount As Integer = 0

Dim cardIndex As Integer = 0

Dim User As String

If(User != End)

'deal the cards

For playerCount = 0 To players - 1

For cardCount = 0 To cardsPerPlayer - 1

hands(playerCount, cardsPerPlayer) = Deck(cardIndex)

cardIndex = cardIndex + 1

Select Case playerCount

Case 0 : Me.ListBox1.Items.Add(StringCard(hands(playerCount, cardsPerPlayer)))

Case 1 : Me.ListBox2.Items.Add(StringCard(hands(playerCount, cardsPerPlayer)))

Case 2 : Me.ListBox3.Items.Add(StringCard(hands(playerCount, cardsPerPlayer)))

Case 3 : Me.ListBox4.Items.Add(StringCard(hands(playerCount, cardsPerPlayer)))

End Select

Next

Next

End If

Return Winner   

End Sub

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