2-Dimensional Array

Hi :). I am making a BlackJack app and to make it more realistic I want to make a card deck for the players. So If person A draws a Card4 there will be only 3xCard4s left. I thought about making a 2D Array.

  1. How do I assign the the value of the first dimension to players hand?
  2. How would I subtract the second dimension by 1 when the cards was drawn?
    Thanks in advance:)

Hmmmm. Why did you decide not to model your deck as if it is a real deck of cards?

Personally I would rather have a card object with a few properties like color, suit, number. By doing that you can have a player collection and a dealer collection and you can then move a card from the one collection to the other. Or if you really want to be realistic you can simulate a dealer shoe (or whatever it is called) and add several sets of 52 cards to it and then “shuffle” them. Then you draw a card by moving the first card in the stack to either the dealre or player collection etc.

Much easier than an array…in my opinion.

I agree with @dracosveen @Justin_Sams . trying to keep track of cards using a 2D array and subtracting from them is going to be more of a challenge then you think. try his approach, all you need is already in his comment.