案例要求:
按照斗地主的规则,完成洗牌发牌的动作。
具体规则:
- 组装54张扑克牌将
- 54张牌顺序打乱
- 玩家参与游戏,三人交替摸牌,每人17张牌,最后三张留作底牌
- 查看三人各自手中的牌(按照牌的大小排序)、底牌
具体代码:
import java.util.*;
public class Text2 {
public static void main(String[] args) {
List color = new ArrayList<>();
List num = new ArrayList<>();
Collections.addAll(color, “♠”, “♣”, “♥”, “♦”);
Collections.addAll(num, “2”, “A”, “K”, “Q”, “J”, “10”, “9”, “8”, “7”, “6”, “5”, “4”, “3”);
Map<Integer, String> poker = new HashMap<>();
int count = 0;
poker.put(++count, "大王");
poker.put(++count, "小王");
for (int i = 0; i < num.size(); i++) {
for (int j = 0; j < color.size(); j++) {
String x = color.get(j) + num.get(i);
poker.p