public class DouDiZhu2 {
public static void main(String[] args) {
HashMap<Integer, String> poker = new HashMap<>();
ArrayList<Integer> pokerIndex = new ArrayList<>();
List<String> colors = List.of("♠", "♥", "♣", "♦");
List<String> nums = 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 num : nums) {
for (String color : colors) {
poker.put(index, color + num);
pokerIndex.add(index);
index++;
}
}
Collections.shuffle(pokerIndex);
ArrayList<Integer> player1 = new ArrayList<>();
ArrayList<Integer> player2 = new ArrayList<>();
ArrayList<Integer> player3 = new ArrayList<>();
ArrayList<Integer> diPai = new ArrayList<>();
for (Integer i : pokerIndex) {
Integer integer = pokerIndex.get(i);
if (i >= 51) {
diPai.add(integer);
} else if (i % 3 == 0) {
player1.add(integer);
} else if (i % 3 == 1) {
player2.add(integer);
} else if (i % 3 == 2) {
player3.add(integer);
}
}
Collections.sort(player1);
Collections.sort(player2);
Collections.sort(player3);
Collections.sort(diPai);
look("卢本伟", poker, player1);
look("阿姨", poker, player2);
look("我", poker, player3);
look("底牌", poker, diPai);
}
public static void look(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();
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-54562.html