{:2_32:}
import java.util.ArrayList;
import java.util.Collections;
import java.util.TreeSet;
public class DouDiZhu {
/**
* @param args
*/
public static void main(String[] args) {
ArrayList<String> pai = new ArrayList<String>();
pai.add("大王");
pai.add("小王");
String[] shuzi = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"J", "Q", "K" };
String[] huase = { "♠", "♦", "♣", "♥" };
for (int i = 0; i < huase.length; i++) {
for (int j = 0; j < shuzi.length; j++) {
pai.add(huase[i].concat(shuzi[j]));
}
}
// System.out.println(pai);
Collections.shuffle(pai);
// System.out.println(pai);
ArrayList<String> GaoYuanYuan = new ArrayList<String>();
ArrayList<String> LiuYiFei = new ArrayList<String>();
ArrayList<String> HuWenHao = new ArrayList<String>();
for (int x = 0; x < pai.size() - 3; x++) {
if (x % 3 == 0) {
GaoYuanYuan.add(pai.get(x));
} else if (x % 3 == 1) {
LiuYiFei.add(pai.get(x));
} else if (x % 3 == 2) {
HuWenHao.add(pai.get(x));
}
}
// System.out.println(GaoYuanYuan);
// System.out.println(LiuYiFei);
// System.out.println(HuWenHao);
for(int x = pai.size()-3;x < pai.size();x++){
System.out.print(pai.get(x)+",");
}
System.out.println();
sort(GaoYuanYuan);
sort(LiuYiFei);
sort(HuWenHao);
}
public static void sort(ArrayList<String> al){
//排序,集合中都是字符串类型,遍历比较
TreeSet<String> ts = new TreeSet<String>(new MyComparator());
for(int x = 0; x<al.size();x++){
ts.add((String)al.get(x));
}
System.out.println(ts);
}
}
|
|