package homework;
import java.util.Collections;
import java.util.LinkedList;
public class DouDiZhu_LinkedList {
public static void main(String[] args) {
LinkedList<String> puKePai = new LinkedList<String>();
String[] huaSe = { "方块", "梅花", "红桃", "黑桃" };
String[] shuZi = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"J", "Q", "K" };
// 买牌
puKePai.add("小王");
for (int i = 0; i < huaSe.length; i++) {
for (int j = 0; j < shuZi.length; j++) {
puKePai.add(huaSe[i] + shuZi[j]);
}
}
puKePai.add("大王");
System.out.println(puKePai);
// 洗牌
Collections.shuffle(puKePai);
// 发牌
LinkedList<String> zhouRunFa = new LinkedList<String>();
LinkedList<String> liuDeHua = new LinkedList<String>();
LinkedList<String> zhouXinChi = new LinkedList<String>();
int zhangShu = (puKePai.size() - 3) / 3;
for (int i = 0; i < zhangShu; i++) {
zhouRunFa.add(puKePai.removeFirst());
liuDeHua.add(puKePai.removeFirst());
zhouXinChi.add(puKePai.removeFirst());
}
System.out.println(zhouRunFa);
System.out.println(liuDeHua);
System.out.println(zhouXinChi);
// 看底牌
System.out.println(puKePai);
}
}
|
|