?
Solved

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

Posted on 2006-06-27
3
Medium Priority
?
262 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
[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
  • Learn & ask questions
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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…

801 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