package com.yuyang.code;
import java.util.ArrayList;
public class Test1 {
/**
1.定义一个静态集合,这样集合只加载一个
*/
public static ArrayList<String> cards=new ArrayList();
/**
2.在main方法之前,把54张牌放进去,后续游戏可以直接使用
*/
static {
//正式做牌,放入集合中
//先定义一个数组存储所有点数,类型确定,个数确定。用数组
String[] sizes={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
//定义一个数组存储花色
String[] colors={"♠","♥","♦","♣"};
//组合点数和花色
for (int i = 0; i < sizes.length; i++) {
// sizes[i]
for (int j = 0; j < colors.length; j++) {
// colors[j]
String card=sizes[i]+colors[j];
cards.add(card);
}
}
//单独加载大小王
cards.add("小王");
cards.add("大王");
}
public static void main(String[] args) {
//目标:模拟游戏前54张扑克牌数据
System.out.println("新牌为:"+cards);
}
}
新牌[3♠, 3♥, 3♦, 3♣, 4♠, 4♥, 4♦, 4♣, 5♠, 5♥, 5♦, 5♣,
6♠, 6♥, 6♦, 6♣, 7♠, 7♥, 7♦, 7♣, 8♠, 8♥, 8♦, 8♣, 9♠,
9♥, 9♦, 9♣, 10♠, 10♥, 10♦, 10♣, J♠, J♥, J♦, J♣
, Q♠, Q♥, Q♦, Q♣, K♠, K♥, K♦, K♣, A♠, A♥, A♦, A♣, 2♠, 2♥, 2♦, 2♣,
小王, 大王]
Process finished with exit code 0