本文共 1139 字,大约阅读时间需要 3 分钟。
java用ArrayList集合来实现斗地主发牌案例
package com.paly;import java.util.ArrayList;import java.util.Collections;public class SetPaly { public static void main(String[] args) { // 花色 String[] color = { "♠","♥","♣","♦" }; // 数字 String[] num = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" }; // 牌盒 ArrayListbox = new ArrayList<>(); for (int i = 0; i < color.length; i++) { for (int j = 0; j < num.length; j++) { box.add(color[i] + num[j]); } } box.add("大王"); box.add("小王"); // 洗牌 Collections.shuffle(box); //System.out.println(box); // 找三个人来打牌 ArrayList
转载地址:http://rjjqb.baihongyu.com/