Uses of Modular Division?

Apr 2 2004 1:19 PM
Hello all - I am attempting to build a game of Texas Hold 'Em in vb.net. In order to do this it is necessary to assign suit values and face values to cards. So far in my project, I have a class of DeckofCards. This DeckofCards class consists of a collection of my own defined objects Ace, 2, 3, 4, etc. I was told that by using the index of this collection (each object 0-51 index value) and dividing modularly will give me suit values and facevalues. While I understand the idea behind this theory, eg, that 51 MOD 4 (4 being the number of suits available) will return 3. On a zero-based scale, 0-3, I can assign 0 to be club, 1 to be spade, etc. Similarly, 51 MOD 13 (13 being the number of different face values in a deck of cards) returns 12. Again 0-12 yields the correct values. My question is this: How do I take the MOD remainder and parcel out the values (0-3 for suits and 0-12 for facevalue) and assign them to the correct object? Keeping in mind that the 0-12 must be assigned to 4 instances of the different suits, ie There are 4 aces in a deckofcards, but only one ace of hearts. In my classes for Ace, 2, 3, 4, etc. I have a readonly property that gets and assigns the value through a private access member mFaceValue and mSuitValue. Any suggestions? Thanks for the time!