public static void main(String[] args) {
ArrayList<String> p = new ArrayList<>();
String[] c = { "♥", "♠", "♦", "♣" }; // 花色
String[] m = { "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A" }; // 点数
for (int i = 0; i < c.length; i++) {
for (int j = 0; j < m.length; j++) {
// System.out.println(p[count]);
p.add(c[i] + m[j]);
}
}
p.add("小王");
p.add("大王");
//System.out.println(p);
// 洗牌
Collections.shuffle(p);
//System.out.println(p);
// 发牌
ArrayList<String> play1 = new ArrayList<>();
ArrayList<String> play2 = new ArrayList<>();
ArrayList<String> play3 = new ArrayList<>();
ArrayList<String> diPai = new ArrayList<>();
for(int i=0;i<p.size()-3;i++){
if(i%3==0){
play1.add(p.get(i));
}else if(i%3==1){
play2.add(p.get(i));
}else{
play3.add(p.get(i));
}
}
for(int i=p.size()-3;i<p.size();i++){
diPai.add(p.get(i));
}
//Collections.sort(play1); //按 码表 排序
paiXun(play1);
paiXun(play2);
paiXun(play3);
paiXun(diPai);
System.out.println("玩家一:"+play1);
System.out.println("玩家二:"+play2);
System.out.println("玩家三:"+play3);
System.out.println("底 牌:"+diPai);
}
运行结果如下:
玩家一:[♠4, ♠5, ♦5, ♣5, ♠6, ♣6, ♥9, ♥10, ♠10, ♠J, ♦Q, ♣Q, ♥K, ♣K, ♠2, ♣2, 大王]
玩家二:[♥3, ♣3, ♥6, ♦7, ♠8, ♦8, ♣8, ♣9, ♥J, ♦J, ♠K, ♦K, ♠A, ♦A, ♣A, ♥2, ♦2]
玩家三:[♠3, ♥4, ♦4, ♣4, ♥5, ♦6, ♥7, ♠7, ♣7, ♠9, ♦9, ♦10, ♣10, ♣J, ♠Q, ♥A, 小王]
底 牌:[♦3, ♥8, ♥Q]
|
|