标题
public class 斗地主 {
public static void main(String[] args) {
TreeMap<Integer, ArrayList<String>> poxBox2 = new TreeMap<>();
HashMap<Integer, String> map = new HashMap<>();
ArrayList<String> poxBox = new ArrayList<>();
String[] colors = {"♥", "♣", "♠", "♦"};
String[] nums = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
int index = 0;
for (String num : nums) {
for (String color : colors) {
poxBox.add(index++, num + color);
}
}
poxBox.add("☀");
poxBox.add("?");
ArrayList<Integer> cards = new ArrayList<>();
for (int j = 0; j <= 53; j++) {
cards.add(j);
}
Collections.shuffle(cards);
ArrayList<Integer> 高进牌号 = new ArrayList<>();
ArrayList<Integer> 刀仔牌号 = new ArrayList<>();
ArrayList<Integer> 星仔牌号 = new ArrayList<>();
ArrayList<Integer> 底牌牌号 = new ArrayList<>();
for (int i = 0; i < cards.size(); i++) {
if (i >= cards.size() - 3) {
底牌牌号.add(cards.get(i));
} else if (i % 3 == 0) {
高进牌号.add(cards.get(i));
} else if (i % 3 == 1) {
刀仔牌号.add(cards.get(i));
} else {
星仔牌号.add(cards.get(i));
}
}
Collections.sort(高进牌号);
Collections.sort(刀仔牌号);
Collections.sort(星仔牌号);
ArrayList<String> 高进 = new ArrayList<String>();
ArrayList<String> 刀仔 = new ArrayList<String>();
ArrayList<String> 星仔 = new ArrayList<String>();
ArrayList<String> 底牌 = new ArrayList<String>();
for (Integer key : 高进牌号) {
高进.add(poxBox.get(key));
}
for (Integer key : 刀仔牌号) {
刀仔.add(poxBox.get(key));
}
for (Integer key : 星仔牌号) {
星仔.add(poxBox.get(key));
}
for (Integer key : 底牌牌号) {
底牌.add(poxBox.get(key));
}
lookPoker("高进", 高进);
lookPoker("刀仔", 刀仔);
lookPoker("星仔", 星仔);
lookPoker("底牌", 底牌);
}
private static void lookPoker(String name, ArrayList<String> list) {
System.out.println(name);
for (String s : list) {
System.out.print(s+" ");
}
System.out.println();
}
}