package com.citi.byteman.test.arithmatic;
import java.util.Random;
public class XiPai {
private String[] singleCard = { "2", "3", "4", "5", "6", "7", "8", "9",
"10", "J", "Q", "K", "A" };
private String[] allCards = new String[54];
// shuffle 100 times, exchange two cards every time
public void shuffleCards() {
allCards = initCard();
String temp = "";
for (int i = 0; i < 100; i++) {
int m = new Random().nextInt(54);
int n = new Random().nextInt(54);
temp = allCards[m];
allCards[m] = allCards[n];
allCards[n] = temp;
}
}
// initial all 54 cards
public String[] initCard() {
for (int i = 0; i < singleCard.length; i++) {
String[] tempCards = addMsg(singleCard[i]);
for (int j = 0; j < 4; j++) {
allCards[i * 4 + j] = tempCards[j];
}
}
allCards[52] = "Big Joke";
allCards[53] = "Small Joke";
return allCards;
}
private String[] addMsg(String card) {
return new String[] { "Black-" + card, "Red-" + card, "Plum-" + card,
"Box-" + card };
}
public void printCurrentCards() {
for (int i = 0; i < allCards.length; i++) {
System.out.println(allCards[i]);
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
XiPai xipai = new XiPai();
xipai.shuffleCards();
xipai.printCurrentCards();
}
}