import java.util.ArrayList;
import java.util.Collections;
public class Main {
public static void main(String[] args) {
//模擬鬥地主的洗牌發牌看牌;
//建立撲克牌
ArrayList<String> arrayList = new ArrayList<>();
//撲克牌(♦ ♣ ♠ ♥)
String[] color = {"♦", "♣", "♠", "♥"};
//牌號(2,3,4,5,6,7,8,9,10,J,Q,K,A)
String[] paihao = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
//大王小王
//用arrilist。add的強迴圈把牌裝起來
for (String c : color) {
for (String p : paihao) {
arrayList.add(c + p);
}
}
arrayList.add("joker");
arrayList.add("小王");
//洗牌
Collections.sort(arrayList);
//發牌
//定義三個人的陣列和一個底牌陣列
ArrayList<String> zsf = new ArrayList<>();
ArrayList<String> jcs = new ArrayList<>();
ArrayList<String> zxt = new ArrayList<>();
ArrayList<String> dipai = new ArrayList<>();
for (int i = 0; i < arrayList.size(); i++) {
String s = arrayList.get(i);
if (i >= arrayList.size() - 3) {
dipai.add(s);
} else if (i % 3 == 1) {
zsf.add(s);
} else if (i % 3 == 2) {
jcs.add(s);
} else if (i % 3 == 0)
zxt.add(s);
}
show("zsf",zsf);
show("jcs",jcs);
show("zxt",zsf);
show("底牌",dipai);
}
//發牌了
public static void show(String s, ArrayList<String> a) {
System.out.print(s + "的牌是 ");
for (String q : a) {
System.out.print(q + " ");
}
System.out.println();
}
//定義遍歷牌的函式被
}