package com.itheima01; import java.util.ArrayList; import java.util.Collections; public class PokerDemo { public static void main(String[] args) { ArrayList<String> array = new ArrayList<String>(); String[] colors = {"♦", "♣", "♥", "♠"}; String[] numbers = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"}; for (String color : colors) { for (String number : numbers) { array.add(color + number); } }a array.add("小王"); array.add("大王"); Collections.shuffle(array); ArrayList<String> lqxArray = new ArrayList<String>(); ArrayList<String> lyArray = new ArrayList<String>(); ArrayList<String> fqyArray = new ArrayList<String>(); ArrayList<String> dpArray = new ArrayList<String>(); for (int i = 0; i < array.size(); i++) { String poker = array.get(i); if (i >= array.size() - 3) { dpArray.add(poker); } else if (i % 3 == 0) { lqxArray.add(poker); } else if (i % 3 == 1) { lyArray.add(poker); } else if (i % 3 == 2) { fqyArray.add(poker); } }lookPoker("林青霞",lqxArray); lookPoker("柳岩",lyArray); lookPoker("风清扬",fqyArray); lookPoker("底牌",dpArray); } public static void lookPoker(String name,ArrayList<String> array){ System.out.print(name+"的牌是:"); for(String poker:array){ System.out.print(poker+" "); } System.out.println(); } }
模拟斗地主
最新推荐文章于 2024-11-04 20:33:37 发布