package com.imooc11;import java.util.ArrayList;import java.util.HashSet;import java.util.List;import java.util.Set;public class Puke { //创建扑克牌属性(没想到) public String num; public String color; public String str1[]={" "}; public String str2[]={" "};public List<Puke>pukes; //定义存放扑克容器//对象实例化public Puke(String color,String num){ this.num=num; this.color=color; this.pukes=new ArrayList<Puke>();}//创建52张扑克牌public void creatPuke(){ String str1[]={"黑桃","红桃","梅花","方片"}; String str2[]={"2","3","4","5","6","7","8","9","10","J","Q","K","A"}; for(int i=0;i<str1.length;i++){ for(int j=0;j<str2.length;j++){ Puke pk=new Puke(str1[i],str2[j]); pukes.add(pk); } }}/* * 遍历扑克牌 */public void forPuke(){ System.out.println("******52张扑克牌******"); for (Puke pk:pukes){ System.out.println(pk.color+":"+pk.num); }} public static void main(String[] args) { // TODO Auto-generated method stub Puke pk=new Puke(); }}
写个无参构造就行了