• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Card Game Ideas - How to handle deck and players hand?

Hello,

I am making a card game, and I was looking for thoughts/ideas on how to proceed.

Currently I have two arrays: one contains the cards in the players hand, and one contains the cards in the deck.  Each array is two dimensional with one column for card number(2, 3, 4, ... Q, K, A) and one column for card suit (C, D, H, S).

The problem I am running into is how to remove the cards in the players hand array from the deck array so that the deck actually has one less row and not just an empty row.

Does anyone have any idea how to do this, or have a better idea on how to accomplish this?

Thanks in advance,
-Torrwin
0
Torrwin
Asked:
Torrwin
1 Solution
 
Bob LearnedCommented:
Idea:

1) Have an Hashtable for the deck:  2C, ... AC, 2D, ... AD, 2H, ... AH,
2) Have a hashtable for each hand
3) When you deal, calculate a random number 1..52, determine the key, remove from the deck table by key, and add to the hand by the key

Bob

   
0
 
tpwellsCommented:
you could define a card structure that has a property for the Suit(C,D,H,S) and Value(2,3...K,A)

Load the cards into an ArrayList for the Deck

two or more other ArrayLists indicate the hands for each player.

As you draw a card from the Deck add it to the playersHand and remove it from the Deck using the ArrayList.Remove() or ArrayList.RemoveAt() method
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now