package ss1;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;
public class DouDiZhu {
public static void main(String[] args) {
HashMap<Integer,String> hm =new HashMap<Integer,String>();
ArrayList<Integer> arrayList =new ArrayList<Integer>();
String[] calors = {"?", "?", "?", "?"};
String[] numbers ={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
int index = 0;
for (String number:numbers) {
for (String calor:calors) {
String value = calor.concat(number);
hm.put(index, value);
arrayList.add(index);
index++;
}
}
hm.put(index, "小王");
arrayList.add(index);
index++;
hm.put(index, "大王");
arrayList.add(index);
//洗牌
Collections.shuffle(arrayList);
//发牌
TreeSet<Integer> aa=new TreeSet<Integer>();
TreeSet<Integer> bb=new TreeSet<Integer>();
TreeSet<Integer> cc=new TreeSet<Integer>();
TreeSet<Integer> diPai=new TreeSet<Integer>();
for (int i = 0; i < arrayList.size(); i++) {
if(i>=arrayList.size()-3){
diPai.add(arrayList.get(i));
}else if(i%3 == 0){
aa.add(arrayList.get(i));
}else if(i%3 == 1){
bb.add(arrayList.get(i));
}else if(i%3 == 2){
cc.add(arrayList.get(i));
}
}
//看牌
show("aa",aa,hm );
show("bb",bb,hm );
show("cc",cc,hm );
show("diPai",diPai,hm );
}
public static void show(String name,TreeSet<Integer> ts,HashMap<Integer,String> hm){
System.out.println(name +":");
for (Integer key: ts) {
System.out.print(hm.get(key));
System.out.print(" ");
}
System.out.println();
}
}
结果;
aa:
4 ?5 ?6 ?7 ?7 ?7 ?8 ?8 ?9 ?10 ?10 ?10 ?J ?Q ?Q ?A ?A
bb:
3 ?4 ?4 ?5 ?6 ?6 ?6 ?8 ?9 ?10 ?J ?K ?A ?2 ?2 ?2 小王
cc:
3 ?3 ?3 ?4 ?5 ?5 ?7 ?9 ?J ?Q ?Q ?K ?K ?K ?A ?2 大王
diPai:
8 ?9 ?J
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。