
package test01;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class pokerList {
public static void main(String[] args) {
HashMap<Integer,String> poker = new HashMap<>();
ArrayList<Integer> pokerIndex = new ArrayList<>();
List<String> colors = List.of("♠","♥" ,"♦","♣");
List<String> numbers = List.of("2","A","K" ,"Q","J","10","9","8","7","6","5","4","3");
int index = 0;
poker.put(index,"大王");
pokerIndex.add(index);
index++;
poker.put(index,"小王");
pokerIndex.add(index);
index++;
for (String number : numbers) {
for (String color : colors) {
poker.put(index,color+number);
pokerIndex.add(index);
index++;
}
}
Collections.shuffle(pokerIndex);
ArrayList<Integer> p1 = new ArrayList<>();
ArrayList<Integer> p2 = new ArrayList<>();
ArrayList<Integer> p3 = new ArrayList<>();
ArrayList<Integer> diPai = new ArrayList<>();
for (int i = 0; i < pokerIndex.size(); i++) {
Integer ind = pokerIndex.get(i);
if(i>=51){
diPai.add(ind);
}else if(i%3==0){
p1.add(ind);
}else if(i%3==1){
p2.add(ind);
}else if(i%3==2){
p3.add(ind);
}
}
Collections.sort(p1);
Collections.sort(p2);
Collections.sort(p3);
Collections.sort(diPai);
lookPoker("张三",poker,p1);
lookPoker("李四",poker,p2);
lookPoker("王五",poker,p3);
lookPoker("底牌",poker,diPai);
}
public static void lookPoker(String name,HashMap<Integer,String> poker,ArrayList<Integer> list){
System.out.print(name + ": ");
for (Integer key : list) {
String value = poker.get(key);
System.out.print(value + " ");
}
System.out.println();
}
}