Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Adding cards back into deck

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Adding cards back into deck

    I should be able to figure this out, but I'm completely lost.

    The following code deals to a hand of choice a set number of cards (int toDeal):
    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();
                hand.setHand(s);
            }
        }

    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
    -sp4ce
    Last edited by sp4ce; February 14th, 2011 at 07:25 PM.


  2. #2
    Member DanBrown's Avatar
    Join Date
    Jan 2011
    Posts
    134
    My Mood
    Confused
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Default Re: Adding cards back into deck

    Your question is not clear to me , if it is possible can you make it more clear.
    Thanks and Regards
    Dan Brown

    Common Java Mistakes

Similar Threads

  1. Sorting a deck of cards by suite or rank.
    By coyne20 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 13th, 2010, 08:47 AM
  2. I'm back
    By Brt93yoda in forum The Cafe
    Replies: 3
    Last Post: November 15th, 2010, 10:29 PM
  3. control Browser Back Button
    By Ganezan in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: December 30th, 2009, 07:49 AM
  4. Forgot to back up
    By WebPVP in forum Java Theory & Questions
    Replies: 5
    Last Post: October 13th, 2009, 07:13 PM