public static void main(String[] args) {
//牌的类型
ArrayList<String> arrayList = new ArrayList<>();
String arry[]={"A","2","K","Q","J","3","4","5","6","7","8","9","10"};
String arryType[]={"■","♣","♥","♠"};
for (int i = 0; i < arryType.length; i++) {
for (int i1 = 0; i1 < arry.length; i1++) {
arrayList.add(arryType[i]+arry[i1]);
}
}
arrayList.add("大王");
arrayList.add("小王");
Collections.shuffle(arrayList);
//定义三个玩家,和底牌
ArrayList<String> player1 = new ArrayList<>();
ArrayList<String> player2 = new ArrayList<>();
ArrayList<String> player3 = new ArrayList<>();
ArrayList<String> player4 = new ArrayList<>();
// 发牌
for (int i = arrayList.size() - 1; i >= 0; i--) {
if (i<=2){
player4.add(arrayList.get(i));
}else if(i%3==0){
player1.add(arrayList.get(i));
}else if (i%3==1){
player2.add(arrayList.get(i));
}else if(i%3==2){
player3.add(arrayList.get(i));
}
}
// 分别打印出发牌的数据
System.out.println(player1);
System.out.println(player2);
System.out.println(player3);
System.out.println(player4);
}
12-01