Solved

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

Posted on 2006-06-27
Medium Priority
262 Views
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?

-Torrwin
0
Question by:Torrwin
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 96

Expert Comment

ID: 16997376
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

LVL 10

Accepted Solution

tpwells earned 2000 total points
ID: 17003280
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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
###### Suggested Courses
Course of the Month13 days, 10 hours left to enroll