package com.imooc.pukeyouxi;import java.util.ArrayList;import java.util.List;public abstract class puke { public String huase; public String dianshu; public puke(String huase,String dianshu){ this.huase=huase; this.dianshu=dianshu; } public puke(){ } }package com.imooc.pukeyouxi;import java.util.ArrayList;import java.util.List;/*?*??* 加入整個撲克 ? ?我覺得此處用map<>更好,有坐標(biāo)及內(nèi)容。通過坐標(biāo)比較?* 但是list 可以做位置的比較?* */public class listpuke { public List<puke> pukelist=new ArrayList<puke>(); public void addall(){ //建立點數(shù)數(shù)組 String [] dianshuji={"2","3","4","5","6","7","8","9","10","J","Q","K","A"}; //建立花色數(shù)組 String [] huaseji={"方塊","梅花","紅桃","黑桃"}; for(int i=0;i<huaseji.length;i++){ for(int j=0;j<dianshuji.length;j++){ puke cr1=new puke(huaseji[i],dianshuji[j]);//此處提示異常,不能實力化 類型 是什么問題???求解 pukelist.add(cr1); } } System.out.println("--------------撲克拆包成功:-----------"); System.out.println("目前撲克牌為:"); for(puke list:pukelist){ System.out.println(list); }}}
撲克牌問題求解,提示puke不能實例化類型
qq_奔三了_03545151
2016-07-05 12:57:34