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: Need help with Deck of Cards

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Need help with Deck of Cards

    Ok so right now I'm in my Java class in school and today we were tasked with making a program that simulates a deck of cards, where you select a random card, and once you get the card, it cant show up again, as in it gets 'discarded' and you cant use it again, and once all 52 cards have been selected (Jokers wont be used in this), the program prompts the user if they want to select again.
    Ok so my problem isnt the program itself, I know how to make a program that selects a random card and such, and I know that I can store that card in a variable for one extra round, so the card isn't used twice in a row, but honestly I think there's an easier way to simulate a whole deck rather than make 52 different variables. From what I understand, there's a way to do it involving arrays, but I'm not really sure how those work and also I think that's our next lesson and this project is a preview for it so I'm not sure if there's an easier way than 52 variables except arrays. Can I get a senior Java coder's opinion/help on this please?


  2. #2
    Junior Member
    Join Date
    Mar 2012
    Location
    Brasilia (Brasil)
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Need help with Deck of Cards

    I think I didnot understand your problem very well. The problem is just to create a boolean array with 52 positions (true) and when the card is randomly selected, the boolean array position goes to false? Therefore you may have two arrays: a String array with the name of the card and another Boolean array that says whether the card was selected or not?

Similar Threads

  1. A deck of cards
    By glebovg in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 1st, 2012, 09:46 AM
  2. I'm making a program that recognizes cards say for poker
    By Lurie1 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: February 13th, 2012, 04:44 PM
  3. Adding cards back into deck
    By sp4ce in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 15th, 2011, 01:21 AM
  4. 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