I've been assigned a program with arrays to build a deck of cards, and I need a program to shuffle the deck. I have no idea where to start. I considered creating a new method named shuffleDeck, but I'm not sure if it would work properly with the two arrays. Arrays are a generally new topic to me, and I'm not sure how to shuffle the deck when there are two arrays building each separate card.
No direct answers please, but some hints/help with this would be greatly appreciated.
EDIT: I tried using Collections.shuffle, and it seems that it's not building properly with Strings.
import java.util.*;
import java.io.*;
public class cards_st {
public static void main(String[] args) {
String [] card = {"2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"};
String [] suit = {" of hearts"," of clubs"," of spades", " of diamonds"};
String [] odeck = new String[52];
buildDeck(odeck,card,suit);
for(int d = 0; d <52; d++)
System.out.println(odeck[d]);
}
public static void buildDeck(String [] tdeck,String [] tcard, String [] tsuit)
{
int count = 0;
for (int i = 0; i < 13; i++)
{
for (int j = 0; j < 4; j++)
{
tdeck[count]= tcard[i] + tsuit[j];
count++;
}
}
}
}