Solved

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

Posted on 2006-06-27
3
258 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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