斗地主部分代码示例(参照传智播客视频)

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, "
上一篇:JAVA基础(TreeSet存储自定义对象比较排序)


下一篇:JAVA基础(TreeSet比较器排序原理)