public class datapoke {
string pokepoint;//点数 【程序编程相关:MySQL的驱动引起Hibernate无】string pokeface;//牌面 【推荐阅读:《CSDN社区电子杂志——java杂志》】
string pokeimgpath;//扑克图片对应地址 【扩展信息:Jsp中使用xmlhttp进行数据交互~】 string pokecolor;//花色 boolean useflag = false;//是否使用标记false未使用,true使用中public datapoke() {
} public void setuserflag(boolean flag){ this.useflag = flag; } public boolean getuserflag(){ return this.useflag; } public string getpoint(){ return this.pokepoint; } public string getcolor(){ return this.pokecolor; } public string getimgpath(){ return this.pokeimgpath; } public string getpokeface(){ return this.pokeface; }}
///////////////////////////////////////////////////////////////////////
import java.util.*;
public class pokebean {
private string [] color = {"black","red","flower","sequa"}; private string pokeimgurl = "/m/g/bj/images/"; private linkedlist pokelist = new linkedlist();//poke链表列表 datapoke[] datapoke = new datapoke[52]; public pokebean() { } public void initpokelist(){ for(int i=0; i<=51; i++) { datapoke[i] = new datapoke();//初始化52个datapoke类变量存储 } int over = 10; int count=0; for(int i=1; i<=13; i++){ for(int j=1; j<=4; j++){ if(i<10) datapoke[count].pokepoint = "" + i;//点数1-10 else datapoke[count].pokepoint = "" + over; //点数11-13 datapoke[count].pokeface = ""+i;//牌面 datapoke[count].pokecolor = color[j-1];//牌色1-4: 黑 红 梅 方 datapoke[count].pokeimgpath = pokeimgurl+integer.tostring(i)+"/"+integer.tostring(j)+".png"; datapoke[count].setuserflag(false); pokelist.add(count,datapoke[count]);//将用内部类datapoke初始化好的52张牌放置于linkedlist中 //system.out.println("after insert poke --------- = "+count); count=count+1; } } } //初始化完毕后,进行洗牌//这里暂且不用此功能 public void washpokelist(){ int temp1 = 0; int temp2 = 0; linkedlist pokelisttemp = new linkedlist(); for(int i=0; i<this.pokelist.size(); i++){ temp1 = (int)(math.random()*100)%51;//取1-52之间的随机数 while(temp2 == temp1) temp1 = (int)(math.random()*100)%51;//如果出现重复的随机数,重新取 pokelisttemp.add(i,this.pokelist.get(temp1));//依次将乱序的pokedata对象插入 temp2 = temp1; } setuserlinklist(pokelisttemp); }... 下一页