package poker;
import java.util.*;
public class Poker002 {
public static void main(String[] args) {
String[] num = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
String[] color = {"♥", "♣", "♦", "♠"};
//用双列集合来装牌
HashMap<Integer, String> poker = new HashMap<>();
List<Integer> arrIndex = new ArrayList<>();
int index = 0;
for (String n : num) {
for (String c : color) {
arrIndex.add(index);
poker.put(index, c.concat(n));
index++;
}
}
arrIndex.add(index);
poker.put(index, "🃏");
index = index + 1;
arrIndex.add(index);
poker.put(index, "🃏");
//洗牌,针对索引进行打乱顺序
Collections.shuffle(arrIndex);
//游戏参与者
TreeSet<Integer> gaojin = new TreeSet<>();
TreeSet<Integer> longwu = new TreeSet<>();
TreeSet<Integer> me = new TreeSet<>();
TreeSet<Integer> dipai = new TreeSet<>();
List<TreeSet<Integer>> player= Arrays.asList(gaojin,longwu,me,dipai);
//发牌
for (int i = 0; i < arrIndex.size(); i++) {
if (i >= arrIndex.size() - 3) {
dipai.add(arrIndex.get(i));
}else if (i % 3 == 0) {
gaojin.add(arrIndex.get(i));
}else if (i % 3 == 1) {
longwu.add(arrIndex.get(i));
}else {
me.add(arrIndex.get(i));
}
}
//看牌
for(TreeSet<Integer> play:player){
for(int i:play){
System.out.print(poker.get(i));
}
System.out.println();
}
}
}