M
MC
Hi Folks. MC Again, thanks for your advice earlier,
i cracked it and i thought i'd share my final Deck Dealing with you. I know
have to figure out a solution to what hand am I holding. But thats for
another time.
Public Class DeckOfCards
Public Enum Suit
Clubs
Spades
Diamonds
Hearts
End Enum
Public Enum Face
Ace
Two
Three
Four
Five
Six
Seven
Eight
Nine
Ten
Jack
Queen
King
End Enum
Public Class Card
Implements IComparable
Public ReadOnly Suit As Suit
Public ReadOnly Face As Face
Public ReadOnly random As Integer
Public Sub New(ByVal suit As Suit, ByVal face As Face, ByVal Random As
Integer)
Me.Suit = suit
Me.Face = face
Me.random = Random
End Sub
Public Function CompareTo(ByVal obj As Object) As Integer Implements
System.IComparable.CompareTo
Dim c As Card = obj
Return (Me.random - c.random)
End Function
End Class
Public Shared Function Deck()
Dim pack As ArrayList = New ArrayList(51)
Dim r As New Random
For s As Suit = Suit.Clubs To Suit.Hearts
For f As Face = Face.Ace To Face.King
Dim m_card As New Card(s, f, r.Next(1, 99999))
pack.Add(m_card)
Next
Next
pack.Sort()
Return pack
End Function
End Class
Cheers guys
i cracked it and i thought i'd share my final Deck Dealing with you. I know
have to figure out a solution to what hand am I holding. But thats for
another time.
Public Class DeckOfCards
Public Enum Suit
Clubs
Spades
Diamonds
Hearts
End Enum
Public Enum Face
Ace
Two
Three
Four
Five
Six
Seven
Eight
Nine
Ten
Jack
Queen
King
End Enum
Public Class Card
Implements IComparable
Public ReadOnly Suit As Suit
Public ReadOnly Face As Face
Public ReadOnly random As Integer
Public Sub New(ByVal suit As Suit, ByVal face As Face, ByVal Random As
Integer)
Me.Suit = suit
Me.Face = face
Me.random = Random
End Sub
Public Function CompareTo(ByVal obj As Object) As Integer Implements
System.IComparable.CompareTo
Dim c As Card = obj
Return (Me.random - c.random)
End Function
End Class
Public Shared Function Deck()
Dim pack As ArrayList = New ArrayList(51)
Dim r As New Random
For s As Suit = Suit.Clubs To Suit.Hearts
For f As Face = Face.Ace To Face.King
Dim m_card As New Card(s, f, r.Next(1, 99999))
pack.Add(m_card)
Next
Next
pack.Sort()
Return pack
End Function
End Class
Cheers guys