package utils;
import general.Card;
import general.Symbol;
import general.Title;
import java.util.Arrays;
import java.util.Random;
public class CardUtils {
private static Random rand = new Random(System.currentTimeMillis());
public static Card[] createAll(){
Card[] cards = new Card[52];
int pos = 0;
for (Title t : Title.values())
{
for (Symbol symbol : Symbol.values()){
cards[pos] = new Card(t, symbol);
pos++;
}
}
return cards;
}
public static void shuffle(Card[] cards){
int top = cards.length;
Card temp;
while (top > 0)
{
int num = rand.nextInt(top);
temp = cards[num];
top--;
cards[num] = cards[top];
cards[top] = temp;
}
}
public static void shuffle(Object[] cards){
int top = cards.length;
while (top > 0)
{
int num = rand.nextInt(top);
top--;
Object temp = cards[num];
cards[num] = cards[top];
cards[top] = temp;
}
}
public static void shuffle(int[] nums){
int top = nums.length;
int temp;
while (top > 0)
{
int num = rand.nextInt(top);
top--;
temp = nums[num];
nums[num] = nums[top];
nums[top] = temp;
}
}
public static Card[][] sort(Card[][] cards)
{
Card[][] ans = new Card[cards.length][];
for (int j = 0; j < cards.length; j++) {
ans[j] = new Card[cards[j].length];
System.arraycopy(cards[j],0,ans[j],0,cards[j].length);
Arrays.sort(ans[j]);
}
return ans;
}
}