创建扑克牌时List add方法和预想的不一样
public void pokerSetUp(){
Poker pokerCard = new Poker();
List pokerList = new ArrayList();
String[] pokerstr1 = {"黑桃","红桃","梅花","方片"};
String[] pokerstr2 = {"2","3","4","5","6","7","8","9","10","J","Q","k"};
System.out.println("----------创建扑克牌----------");
for(int i=0;i < 4;i++){
for(int j=0;j < 12;j++){
pokerCard.pokercard1 = pokerstr1[i];
// System.out.println(pokerstr1[i]);
// System.out.println(pokerCard.pokercard1);
pokerCard.pokercard2 = pokerstr2[j];
// System.out.println(pokerstr2[j]);
// System.out.println(pokerCard.pokercard2);
pokerList.add(pokerCard);
}
}
System.out.println("----------扑克牌创建成功----------");
System.out.println("为:");
/**
* 通过For each访问List
*/
for (Object obj : pokerList) {
Poker cr = (Poker) obj;
System.out.print(cr.pokercard1 + cr.pokercard2 + " ");
}
}