//创建方法,用来创建扑克牌 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); } }
慕斯4360584
慕斯4360584
慕设计2395807
相关分类