Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

adding cards back into deck, poker program

839705Feb 14 2011 — edited Feb 15 2011
I should be able to figure this out, but I'm completely lost.

The following code deals a hand of a set number of cards:
private void deal(Hand hand, int toDeal)
    {
        for (int j = 0; j < toDeal; j++)
        {
            Hand temp = hand.handCards();
            Card[] s = new Card[temp.getNumCards() + 1];
            Card[] q = hand.getHand(); 
            for (int k = 0; k < temp.getNumCards(); k++)
            {
                s[k] = q[k];
            }
            s[s.length - 1] = deck.dealCard(); // ***THE METHOD SHOWN BELOW***
            hand.setHand(s);
        }
    }
deck.dealCard():
  public Card dealCard()
    {
        Card toDeal = cards.get(numCards());
        cards.remove(numCards());
        return toDeal;
    }
to call it I run:
deal(playerHand, 5);
How do I make a method to add these cards back into the deck (the cards from the temp array)?

Thank you,
any ideas or code greatly appreciated
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 15 2011
Added on Feb 14 2011
3 comments
119 views