代码:
import java.util.ArrayList;
import java.util.Collections;
public class Test2 {
public static void main(String[] args) {
String[] num = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
String[] color = {"♥","♠","♦","♣"};
ArrayList<String> poker = new ArrayList<>();
for (String s1 : color) {
for (String s2 : num) {
poker.add(s1.concat(s2));
}
}
poker.add("大王");
poker.add("小王");
Collections.shuffle(poker);
ArrayList<String> zhangsan = new ArrayList<>();
ArrayList<String> lisi = new ArrayList<>();
ArrayList<String> wangwu = new ArrayList<>();
ArrayList<String> dipai = new ArrayList<>();
for (int i = 0; i < poker.size(); i++) {
if (i >= poker.size() - 3) {
dipai.add(poker.get(i));
}else if (i % 3 == 0) {
zhangsan.add(poker.get(i));
}else if (i % 3 == 1) {
lisi.add(poker.get(i));
}else {
wangwu.add(poker.get(i));
}
}
System.out.println(poker);
System.out.println(zhangsan);
System.out.println(lisi);
System.out.println(wangwu);
System.out.println(dipai);
}
}