模拟斗地主洗牌和发牌
public class MyTest {
public static void main(String[] args) {
//案例演示:
//模拟斗地主洗牌和发牌,牌没有排序
//得有一副牌
ArrayList<String> pokerBox = new ArrayList<>();
//生成54张牌放到牌盒里面
String[] colors = {"♠", "♥", "♦", "♣"};
String[] nums = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
for (String color : colors) {
for (String num : nums) {
pokerBox.add(color.concat(num));
}
}
//手动添加大小王
pokerBox.add("★");
pokerBox.add("☆");
//洗牌
Collections.shuffle(pokerBox);
Collections.shuffle(pokerBox);
Collections.shuffle(pokerBox);
//发牌
ArrayList<String> 高进 = new ArrayList<>