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?
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?