Solved

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

Posted on 2006-06-27
3
245 Views
Last Modified: 2012-05-05
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
Comment
Question by:Torrwin
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
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

by:
tpwells earned 500 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now