基本图解
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210530192946624.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3E0NDUxNzI4,size_16,color_FFFFFF,t_70#pic_center)
代码实现(需要JDK9)
public class NewPractice {
public static void main(String[] args) {
HashMap<Integer, String> concret = new HashMap<>();
ArrayList<Integer> pokerIndex = new ArrayList<>();
List<String> pokerPat = List.of("♥", "♠", "♣", "♦");
List<Integer> pokerNum = List.of("3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2");
int index = 0;
concret.put(index,"大王");
pokerIndex.add(index);
index++;
concret.put(index,"大王");
pokerIndex.add(index);
index++;
for (String patt : pokerPat) {
for (Integer numm : pokerNum) {
concret.put(index,patt + numm);
pokerIndex.add(index);
index++;
}
}
Collections.shuffle(pokerIndex);
ArrayList<Integer> parti01 = new ArrayList<>();
ArrayList<Integer> parti02 = new ArrayList<>();
ArrayList<Integer> parti03 = new ArrayList<>();
ArrayList<Integer> theFinal = new ArrayList<>();
for (int i = 0; i < pokerIndex.size(); i++) {
Integer conIndex = pokerIndex.get(i);
if(i >= 51) {
theFinal.add(conIndex);
}else if(i % 3 == 0){
parti01.add(conIndex);
}else if(i % 3 == 1){
parti02.add(conIndex);
}else if(i % 3 == 2){
parti03.add(conIndex);
}
}
Collections.sort(parti01);
Collections.sort(parti02);
Collections.sort(parti03);
Collections.sort(theFinal);
detectPoker("小新", concret, parti01);
detectPoker("妮妮", concret, parti02);
detectPoker("风间", concret, parti03);
detectPoker("底牌", concret, theFinal);
}
public static void detectPoker(String name, HashMap<Integer, String> hash, ArrayList<Integer> arr) {
System.out.println(name + ":");
Set<Map.Entry<Integer, String>> entries = hash.entrySet();
for (Map.Entry<Integer, String> entry : entries) {
String value = entry.getValue();
System.out.print(value + " ");
}
System.out.println();
}
}