import java.util.Random;
public class CardDeck
{
private String deck[] = new String[52];
private String shapes[] = {"heart", "club", "spade", "diamond"};
private String numbers[] = {"ace", "deuce", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"};
public void CreateDeck()
{
for(int s =0; s < shapes.length; s++)
{
for(int n=0; n<numbers.length;n++)
{
deck[s*13+n] = shapes[s] + " " + numbers[n];
}
}
}
public void Shuffle()
{
Random r = new Random();
int loc1, loc2;
for(int i=0; i<1000;i++)
{
loc1 = r.nextInt(52);
loc2 = r.nextInt(52);
String tmp = deck[loc1];
deck[loc1] = deck[loc2];
deck[loc2] = tmp;
}
}
public void DealCards()
{
for (int i = 0; i < 5; i++)
{
System.out.println(deck[i]);
}
}
}
I've been thinking over this problem for the whole weekends, and still figuring out on HOW CAN I BREAK DOWN THE deck[] so that I can read what is the number of the card and the suit it has? :( I'm really confused! Thanx so much!!!!