package pokergame;
import java.util.ArrayList;
import java.util.Collections;
public class BlackJack {
private static ArrayList<StringBuffer> poker = new ArrayList<StringBuffer>();
private BlackJack() {
}
//静态方法初始化扑克并返回扑克
public static ArrayList<StringBuffer> getPoker() {
if (!poker.isEmpty())
poker.clear();
for (Integer i = 2; i < 15; i++) {
for (int j = 1; j < 5; j++) {
switch (j) {
case 1:
poker.add(new StringBuffer("方块" + i.toString()));
break;
case 2:
poker.add(new StringBuffer("梅花" + i.toString()));
break;
case 3:
poker.add(new StringBuffer("红桃" + i.toString()));
break;
case 4:
poker.add(new StringBuffer("黑桃" + i.toString()));
}
}
}
for (StringBuffer s : poker) {
if (s.lastIndexOf("11") != -1) {
s.replace(2, 4, "J");
}
if (s.lastIndexOf("12") != -1) {
s.replace(2, 4, "Q");
}
if (s.lastIndexOf("13") != -1) {
s.replace(2, 4, "K");
}
if (s.lastIndexOf("14") != -1) {
s.replace(2, 4, "A");
}
}
Collections.shuffle(poker);
return poker;
}
//刷新poker(pool是发出去的牌,在Player类中)
public static void refresh() {
poker.addAll(Player.pool);
}
}
打开App,阅读手记