public static void main(String[] args) {
String[] pai = new String[] { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2" };
// String[] hs = new String[] { "♥", "♠", "♦", "♣" };
HashMap<String, Integer> hj = new HashMap<>();
HashMap<String, Integer> hy = new HashMap<>();
HashMap<String, Integer> hb = new HashMap<>();
List<String> a = new ArrayList<String>();
for (int i = 0; i < pai.length; i++) {
a.add(pai[i]);
a.add(pai[i]);
a.add(pai[i]);
a.add(pai[i]);
}
a.add("大王");
a.add("小王");
Random rand = new Random();
String temp = null;
for (int k = 0; k < 100; k++) {
int p = a.size();
int l = rand.nextInt(p);
int m = rand.nextInt(p);
if (l == m)
continue;
{
temp = a.get(l);
a.set(l, a.get(m));
a.set(m, temp);
}
}
// Collections.shuffle(a);
List<String> j = new ArrayList<String>();
List<String> y = new ArrayList<String>();
List<String> b = new ArrayList<String>();
List<String> d = new ArrayList<String>();
for (int i = 0; i < a.size(); i++) {
if (i >= a.size() - 3) {
d.add(a.get(i));
} else if (i % 3 == 0) {
j.add(a.get(i));
} else if (i % 3 == 1) {
y.add(a.get(i));
} else if (i % 3 == 2) {
b.add(a.get(i));
}
}
System.out.println(d);
System.out.println("甲" + j);
System.out.println("乙" + y);
System.out.println("丙" + b);
for (String str : j) {
if (hj.containsKey(str)) {
hj.put(str, hj.get(str) + 1);
} else
hj.put(str, 1);
}
System.out.println("j" + hj);
for (String str : y) {
if (hy.containsKey(str)) {
hy.put(str, hy.get(str) + 1);
} else
hy.put(str, 1);
}
System.out.println("y" + hy);
for (String str : b) {
if (hb.containsKey(str)) {
hb.put(str, hb.get(str) + 1);
} else
hb.put(str, 1);
}
System.out.println("b" + hb);
我已经实现的代码,请问用枚举法可以实现得出手中牌的牌型吗,可以的话代码是什么急求,就在我这个代码上面加!!!