Arrays as discussed earlier

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
 
C

Cor Ligthert [MVP]

MC,

Thanks however if you share it next time, than you can better do it as a
reply to the ones who did help you in that message.

It shows those people and others that you took their advice and that it was
good.

It helps others who search the newsgroup why you did it.

Thanks in advance.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top