猿问
下载APP

为什么输出的扑克总是红桃A

//创建方法,用来创建扑克牌
public void creatPoker() {
    System.out.println("--------------创建扑克牌----------------");
    System.out.println("扑克牌创建成功!");
    //使用switch语句,用来遍历花色和数字
    for (int i = 0; i < 4; i++) {
        switch (i) {
            case 0:
                cardType = "方片";
                break;
            case 1:
                cardType = "梅花";
                break;
            case 2:
                cardType = "黑桃";
                break;
            case 3:
                cardType = "红桃";
                break;
        }
        for (int j = 2; j <= 14; j++) {
            if (j > 10) {
                switch (j) {
                    case 11:
                        cardNumber = "J";
                        break;
                    case 12:
                        cardNumber = "Q";
                        break;
                    case 13:
                        cardNumber = "K";
                        break;
                    case 14:
                        cardNumber = "A";
                        break;
                }
            } else {
                cardNumber = j + "";
            }
            System.out.println("已添加扑克:" + cardType + cardNumber);
            pokerList.add(new Poker(cardType, cardNumber));
        }
    }
    for (Poker temp : pokerList) {
        System.out.println("扑克牌为:" + temp.cardType + temp.cardNumber);
    }
}


慕斯卡8332134
浏览 123回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP
我要回答