首页 > 技术文章 > 斗地主部分代码示例(参照传智播客视频)

kukai 2019-06-30 21:42 原文

package poker;

import java.util.*;

public class Poker002 {
public static void main(String[] args) {
String[] num = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
String[] color = {"♥", "♣", "♦", "♠"};
//用双列集合来装牌
HashMap<Integer, String> poker = new HashMap<>();
List<Integer> arrIndex = new ArrayList<>();
int index = 0;
for (String n : num) {
for (String c : color) {
arrIndex.add(index);
poker.put(index, c.concat(n));
index++;
}
}
arrIndex.add(index);
poker.put(index, "

推荐阅读