so far this is what I have
import java.util.Random;
public class DeckOfCards
{
public static final int DECK_SIZE = 52;
//Instance Variables
private boolean[] de
Based on your comments you have to use a boolean array where true
indicates that the card is there.
First Point:
So when you construct the deck is it filled or empty?
I would assume it would be full, so what should the value of each cell be?
Second Point:
In the constructor you use:
deck = new boolean[52];
Which is perfectly valid but you also have
public static final int DECK_SIZE = 52;
declared so I would assume you should be using DECK_SIZE
where applicable.
Third Point:
You have two fields:
private int cardsInDeck;//Number of cards currently in the deck
private Random dealer; //Used to rendomly select a card to be dealt
Which are not initialized in your constructor (at least not in the part you posted)
Final Point:
The constructor method should not do anything except setup your local fields. So if you fix your deck
initialization and initialize your other fields you should be good for the constructor. The majority of the work in this case will be done in the function that draws a card.
EDIT:
To draw a card you'll have to
drawACard()
that either prints out or returns the card drawndealer
) (save the index)true
/false
in the deck should help here)deck
appropriately"Ace of Clubs"
you can do whatever you need to with thatSo the main part of your implementation will be how to change something where you have index=5
into the String
"Six of Clubs"
.