仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1848|回复: 20
打印 上一主题 下一主题

[学习教程] JAVA网页设计本人写的一个JSP小游戏21点,纪录一下

[复制链接]
飘灵儿 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-18 11:32:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
还有就是总有人问我到底该学习什么语言,什么语言有前途,那么我的回答是不论是C,C++,java,.net,ruby,asp或是其他语言都可以学,编程的关键不是语言,而是思想。jspublicclassDataPoke{

StringpokeFace;//牌面
Stringpokepoint;//点数
StringpokeColor;//花样
StringpokeImgPath;//扑克图片对应地点
booleanuseFlag=false;//是不是利用标志false未利用,true利用中

publicDataPoke(){
}
publicvoidsetuserFlag(booleanflag){
this.useFlag=flag;
}
publicbooleangetuserFlag(){
returnthis.useFlag;
}
publicStringgetPoint(){
returnthis.pokepoint;
}
publicStringgetColor(){
returnthis.pokeColor;
}
publicStringgetImgPath(){
returnthis.pokeImgPath;
}
publicStringgetpokeFace(){
returnthis.pokeFace;
}

}



///////////////////////////////////////////////////////////////////////



importjava.util.*;

publicclasspokeBean{
privateString[]color={"black","red","flower","sequa"};
privateStringpokeImgurl="/m/g/bj/images/";
privateLinkedListpokeList=newLinkedList();//poke链表列表
DataPoke[]dataPoke=newDataPoke[52];
publicpokeBean(){
}
publicvoidinitPokeList(){
for(inti=0;i<=51;i++)
{
dataPoke[i]=newDataPoke();//初始化52个datapoke类变量存储
}
intover=10;
intcount=0;
for(inti=1;i<=13;i++){
for(intj=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("afterinsertpoke---------="+count);
count=count+1;
}
}
}
//初始化终了后,举行洗牌//这里临时不必此功效
publicvoidwashPokeList(){
inttemp1=0;
inttemp2=0;
LinkedListpokeListtemp=newLinkedList();
for(inti=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);
}

publicLinkedListgetuserLinklist(){
returnthis.pokeList;
}
publicvoidsetuserLinklist(LinkedListpokeListtemp){
this.pokeList=pokeListtemp;
}
publicvoidprintBack(){
LinkedListtemp=getuserLinklist();
for(inti=0;i<temp.size();i++){
DataPoketempDP=(DataPoke)temp.get(i);
System.out.println("********************"+i+"*********************");
System.out.println("------------牌面"+tempDP.pokeFace);
System.out.println("------------点数"+tempDP.pokepoint);
System.out.println("------------花样"+tempDP.pokeColor);
System.out.println("------------地点"+tempDP.pokeImgPath);
System.out.println("------------是不是利用中"+tempDP.useFlag);
}
}
}

/////////////////////////////////////////////////////////////////////////////



publicclasspackageDb{
privateStringuserName;//用户名
privateStringuserPswd;//暗码
privatelongnumuserguid;//用户GUID
privatelongnumsex;//用户性别
privatelongnumage;//用户岁数
privatelongnummoney;//用户点数
privatelongnumwincount;//用户成功局数
privatelongnumlostcount;//用户失利局数
publicpackageDb(){
}
//////////////////////////////////////////numwincount
publiclonggetNumwincount(){
returnthis.numwincount;
}
publicvoidsetNumwincount(longnumwincount){
this.numwincount=numwincount;
}
//////////////////////////////////////////numlostcount
publiclonggetNumlostcount(){
returnthis.numlostcount;
}
publicvoidsetNumlostcount(longnumlostcount){
this.numlostcount=numlostcount;
}
//////////////////////////////////////////numuserguid
publiclonggetNumuserguid(){
returnthis.numuserguid;
}
publicvoidsetNumuserguid(longnumuserguid){
this.numuserguid=numuserguid;
}
///////////////////////////////////////////numsex
publiclonggetNumsex(){
returnthis.numsex;
}
publicvoidsetNumsex(longnumsex){
this.numsex=numsex;
}
////////////////////////////////////////////numage
publiclonggetNumage(){
returnthis.numage;
}
publicvoidsetNumage(longnumage){
this.numage=numage;
}
////////////////////////////////////////////nummoney
publiclonggetNummoney(){
returnthis.nummoney;
}
publicvoidsetNummoney(longnummoney){
this.nummoney=nummoney;
}
////////////////////////////////////////////userName
publicStringgetUserName(){
returnthis.userName;
}
publicvoidsetUserName(StringuserName){
this.userName=userName;
}
////////////////////////////////////////////掏出用户基础信息,需先setUserGuid()
publicvoidgetUserInfo()throwsException{
Stringsql="select*fromUSERwhereNUMUSERGUID="+numuserguid+"";
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
if(DBwork.result.next())
{
setUserName(DBwork.result.getString("VC2USERNAME"));
setNummoney(DBwork.result.getLong("NUMMONEY"));
setNumage(DBwork.result.getLong("NUMAGE"));
setNumsex(DBwork.result.getLong("NUMSEX"));
setNumlostcount(DBwork.result.getLong("NUMLOSTCOUNT"));
setNumwincount(DBwork.result.getLong("NUMWINCOUNT"));
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("getUserInfo掏出用户基础信息堕落"+e);
}
}
/////////////////////////////////////////////反省新用户注册名是不是占用
publicbooleancheckUserInfo(StringuserNameNew)throwsException{
Stringsql="select*fromUSERwhereVC2USERNAME="+userNameNew+"";
//System.out.println("-------------before-sql:"+sql);
booleantemp=true;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
//System.out.println("-------------after-sql:"+sql);
if(DBwork.result.next())
{
temp=true;
}else{
temp=false;
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("checkUserInfo反省新用户注册名是不是占用堕落"+e);
}
returntemp;//用户名已被占用,前往true,不然前往false;
}
/////////////////////////////////////////////拔出新用户注册信息
publicvoidinsertUserNew(StringuserNamenew,Stringpassword,longsex,longage)throwsException{
Stringsql="insertintoUSER(NUMUSERGUID,VC2USERNAME,VC2PASSWORD,NUMSEX,NUMAGE)values(";
sql=sql+"MOBJSEQ.NEXTVAL,";
sql=sql+userNamenew+",";
sql=sql+password+",";
sql=sql+sex+",";
sql=sql+age+")";
//System.out.println("-------------before-sql:"+sql);
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
//System.out.println("------------after--sql:"+sql);
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("insertUserNew拔出新用户注册信息堕落"+e);
}
}
/////////////////////////////////////////////依据用户名失掉用户guid
publiclonggetUserGuid(Stringun)throwsException{
Stringsql="selectNUMUSERGUIDfromUSERwhereVC2USERNAME="+un+"";//
longtemp=0;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
if(DBwork.result.next())
{
temp=DBwork.result.getLong("NUMUSERGUID");
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("getUserGuid依据用户名失掉用户guid堕落"+e);
}
returntemp;
}

/////////////////////////////////////////////反省老用户上岸
publicbooleancheckUserOld(StringuserNameOld,Stringpassword)throwsException{
Stringsql="select*fromUSERwhereVC2USERNAME="+userNameOld+"andVC2PASSWORD="+password+"";
booleantemp=true;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
if(DBwork.result.next())
{
temp=true;
}else{
temp=false;
}
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("checkUserOld反省老用户上岸堕落"+e);
}
returntemp;//老用户的上岸用户名和暗码准确无误,前往true,不然前往false;
}
/////////////////////////////////////////////更新用户数据
publicvoidupdateUser(longuserGuid,longuserMoney,longwinCount,longlostCount)throwsException{
Stringsql="updateUSERsetNUMMONEY="+userMoney+",NUMWINCOUNT="+winCount+",NUMLOSTCOUNT="+lostCount+"whereNUMUSERGUID="+userGuid;
try{
DBOBDBwork=newDBOB();
DBwork.execute(sql);
DBwork.releaseResource();
}catch(Exceptione){
System.out.println("updateUser更新用户数据堕落"+e);
}
}
}

///////////////////////////////////////////////////////


importjavax.servlet.http.*;
importjavax.servlet.ServletRequest;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpSession;
importjavax.servlet.jsp.PageContext;
importjava.util.*;//随机数必要利用
importjava.lang.*;


publicclassgamePai{
privateHttpSessionpaiSession;
privatepokeBeanuserPokeBean;
publicgamePai(){
}
//取点数user
publicintgetPointuser(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
intuserValue=0;
//用户点数盘算
for(inti=0;i<pokeLuser.size();i++){
userValue=userValue+Integer.parseInt(((DataPoke)pokeLuser.get(i)).getPoint());
}
returnuserValue;
}
//取点数pc
publicintgetPointpc(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intpcValue=0;
//电脑点数盘算
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
returnpcValue;
}

//判别是不是另有牌//不必作了,由于加了判别标记位
publicbooleangetPaiStatus(PageContextpagecontext)
{
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLall=(LinkedList)session.getAttribute("poketotal");
if(pokeLall.size()<=4)//小于四张牌,就要从头洗牌了
returntrue;
returnfalse;
}
//持续起牌,玩家挪用,每次起牌以后,必要jsp叶面举行判别是不是爆牌,是不是跳转等
publicvoidgetNextPaiuser(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLall=(LinkedList)session.getAttribute("poketotal");
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");

inttemp=(int)(Math.random()*100)%51;//取1-52之间的随机数
while(((DataPoke)pokeLall.get(temp)).getuserFlag()){
temp=(int)(Math.random()*100)%51;
}

pokeLuser.add(pokeLall.get(temp));
((DataPoke)pokeLall.get(temp)).setuserFlag(true);

session.setAttribute("pokeuser",pokeLuser);//拔出用户失掉的牌
session.setAttribute("poketotal",pokeLall);//更新总牌
}
//判别电脑的分数是不是低于16点,低于16点,就前往真,必要电脑主动加牌
//这里应当有jsp叶面挪用
publicbooleanjudgeAddPc16(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");

intpcValue=0;
//用户点数盘算
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
if(pcValue<=16&&pcValue<=21)//满意小于16,然后加了牌以后满意小于21,就再加
returntrue;

returnfalse;
}
//判别电脑的分数是不是高于17点,低于21点,就前往真,必要电脑主动加牌
//这里应当有jsp叶面挪用
publicbooleanjudgeAddPc21(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");

intpcValue=0;
//用户点数盘算
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
if(pcValue>=17&&pcValue<=21)
returntrue;
returnfalse;
}

//电脑要牌
publicvoidgetNextPaipc(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLall=(LinkedList)session.getAttribute("poketotal");
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");

inttemp=(int)(Math.random()*100)%51;//取1-52之间的随机数
while(((DataPoke)pokeLall.get(temp)).getuserFlag()){
temp=(int)(Math.random()*100)%51;
}

pokeLpc.add(pokeLall.get(temp));
((DataPoke)pokeLall.get(temp)).setuserFlag(true);

session.setAttribute("pokepc",pokeLpc);//拔出用户失掉的牌
session.setAttribute("poketotal",pokeLall);//更新总牌
}

//jsp叶面挪用判别user是不是爆牌,true,爆牌,在叶面举行跳转到爆牌叶面
publicbooleanjudgeBusrtuser(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
intuserValue=0;
for(inti=0;i<pokeLuser.size();i++){
userValue=userValue+Integer.parseInt(((DataPoke)pokeLuser.get(i)).getPoint());
if(userValue>21)
returntrue;
}
returnfalse;
}
//判别pc是不是爆牌,true,爆牌
publicbooleanjudgeBusrtpc(PageContextpageContext){
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intpcValue=0;
for(inti=0;i<pokeLpc.size();i++){
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
if(pcValue>21)
returntrue;
}
returnfalse;
}

//获得扑克牌列表user
publicArrayListgetPaiListUser(PageContextpageContext){
ArrayListtemplistuser=newArrayList();
HttpSessionsession=pageContext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
for(inti=0;i<pokeLuser.size();i++){
templistuser.add(((DataPoke)pokeLuser.get(i)).getImgPath());
}
returntemplistuser;
}
//获得扑克牌列表pc
publicArrayListgetPaiListPc(PageContextpageContext){
ArrayListtemplistpc=newArrayList();
HttpSessionsession=pageContext.getSession();
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
for(inti=0;i<pokeLpc.size();i++){
templistpc.add(((DataPoke)pokeLpc.get(i)).getImgPath());
}
returntemplistpc;
}
//开牌形貌封装
publicStringgetKaiPaiDesc(intresultPai){
if(resultPai==2){return"玩家胜!";}
if(resultPai==3){return"农户胜!";}
if(resultPai==4){return"农户BlackJack,农户胜!";}
if(resultPai==5){return"玩家BlackJack,玩家胜!";}
if(resultPai==6){return"玩家爆牌!农户胜!";}
if(resultPai==7){return"农户爆牌!玩家胜!";}
return"";
}
//开牌
publicintkaiPai(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeLuser=(LinkedList)session.getAttribute("pokeuser");
LinkedListpokeLpc=(LinkedList)session.getAttribute("pokepc");
intuserValue=0;
intpcValue=0;
//用户点数盘算
for(inti=0;i<pokeLuser.size();i++){
//DataPokepokeuser=(DataPoke)pokeLuser.get(i);
userValue=userValue+Integer.parseInt(((DataPoke)pokeLuser.get(i)).getPoint());
}
//电脑点数盘算
for(inti=0;i<pokeLpc.size();i++){
//DataPokepokepc=(DataPoke)pokeLpc.get(i);
pcValue=pcValue+Integer.parseInt(((DataPoke)pokeLpc.get(i)).getPoint());
}
//电脑blackJack,电脑成功
if(pokeLpc.size()==2){
//DataPokepokepcF=(DataPoke)pokeLpc.getFirst();
//DataPokepokepcL=(DataPoke)pokeLpc.getLast();
if(((DataPoke)pokeLpc.getFirst()).getpokeFace().equals("1")&&((DataPoke)pokeLpc.getLast()).getpokeFace().equals("11")||
((DataPoke)pokeLpc.getFirst()).getpokeFace().equals("1")&&((DataPoke)pokeLpc.getLast()).getpokeFace().equals("11")){
return4;//电脑blackJack,电脑成功
}
}
//玩家blackJack,玩家成功,分数更加
if(pokeLuser.size()==2){
//DataPokepokeuserF=(DataPoke)pokeLuser.getFirst();
//DataPokepokeuserL=(DataPoke)pokeLuser.getLast();
if(((DataPoke)pokeLuser.getFirst()).getpokeFace().equals("1")&&((DataPoke)pokeLuser.getLast()).getpokeFace().equals("11")||
((DataPoke)pokeLuser.getLast()).getpokeFace().equals("1")&&((DataPoke)pokeLuser.getFirst()).getpokeFace().equals("11")){
return5;//玩家blackJack,玩家成功,分数更加
}
}
if(userValue>pcValue)
return2;//2为玩家成功
if(userValue<=pcValue&&pcValue<=21)
return3;//3为电脑成功
if(userValue>21)
return6;//玩家爆牌
if(pcValue>21&&userValue<=21)
return7;//电脑爆牌

return0;
}
publicvoidinitPai(PageContextpagecontext)
{
userPokeBean=newpokeBean();
paiSession=pagecontext.getSession();//初始化失掉session
userPokeBean.initPokeList();//初始化52扑克
LinkedListpokelistAll=userPokeBean.getuserLinklist();
LinkedListpokelistuser=newLinkedList();
LinkedListpokelistpc=newLinkedList();
//userPokeBean.washPokeList();//初始化以后洗扑克,有成绩,不克不及洗牌
paiSession.setAttribute("poketotal",pokelistAll);//将初始化并洗好的扑克安排于该玩家session中
paiSession.setAttribute("pokeuser",pokelistuser);//初始化用户扑克数据
paiSession.setAttribute("pokepc",pokelistpc);//初始化电脑扑克数据
//userPokeBean.printBack();//打出牌看看
}
//年夜印出来检测一下
publicvoidprintPai()
{
userPokeBean.printBack();
}
//每次从头残局,都要将52张扑克牌的利用标记置为false,未利用
publicvoidresetPai(PageContextpagecontext){
HttpSessionsession=pagecontext.getSession();
LinkedListpokeList=(LinkedList)session.getAttribute("poketotal");
for(inti=0;i<pokeList.size();i++){
((DataPoke)pokeList.get(i)).setuserFlag(false);//一切的牌置为false,未利用
}
session.setAttribute("poketotal",pokeList);//更新总牌
}
//第一次起牌,在扑克牌中随机抽取四张,分离派给玩家和电脑
publicvoidgetFirstPaiuser(PageContextpagecontext)
{
HttpSessionsession=pagecontext.getSession();
//先获得用户的数据
LinkedListpokeListtempuser=(LinkedList)session.getAttribute("pokeuser");
pokeListtempuser.clear();//清空用户扑克数据列表
//LinkedListpokeListtempPC=newLinkedList();
//先从52张点数牌中随机抽取4张,分离为玩家的两张和农户的两张
intinttemp1=0;
intinttemp2=0;
//先将总牌掏出
//paiSession
LinkedListpokeListtempall1=(LinkedList)session.getAttribute("poketotal");

//给玩家的牌
//for(inti=0;i<2;i++){//从两头取2张牌给玩家
//inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数
//inttemp2=(int)(Math.random()*100)%51;
while(inttemp1==inttemp2){
inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数
inttemp2=(int)(Math.random()*100)%51;
}
pokeListtempuser.add(pokeListtempall1.get(inttemp1));
pokeListtempuser.add(pokeListtempall1.get(inttemp2));
((DataPoke)pokeListtempall1.get(inttemp1)).setuserFlag(true);
((DataPoke)pokeListtempall1.get(inttemp2)).setuserFlag(true);

//while(inttemp2==inttemp1&&(((DataPoke)pokeListtempall1.get(inttemp1)).getuserFlag()))//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp1=(int)(Math.random()*100)%51;
//pokeListtempuser.add(pokeListtempall1.get(inttemp1));
//System.out.println("给玩家的牌的地点:"+((DataPoke)pokeListtempall1.get(inttemp1)).getImgPath());
//System.out.println("给玩家的牌的牌面点数:"+((DataPoke)pokeListtempall1.get(inttemp1)).getpokeFace());
//System.out.println("******************************************************");
//pokeListtempuser.a
//将取到的牌置为利用形态
//((DataPoke)pokeListtempall1.get(inttemp1)).setuserFlag(true);
//inttemp2=inttemp1;
//}
session.setAttribute("pokeuser",pokeListtempuser);//拔出用户失掉的牌到用户的session中
session.setAttribute("poketotal",pokeListtempall1);//更新总牌

//从取后的牌中再取2张给电脑
//intinttemp3=0;
//intinttemp4=0;
//再将总牌掏出
//LinkedListpokeListtempall2=(LinkedList)session.getAttribute("poketotal");
//for(inti=0;i<2;i++){//从取后的总牌中再取2张牌给电脑
//inttemp3=(int)(Math.random()*100)%51;//取1-52之间的随机数1
//while(inttemp4==inttemp3&&(((DataPoke)pokeListtempall2.get(inttemp3)).getuserFlag()))//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp3=(int)(Math.random()*100)%51;
//pokeListtempPC.add(i,pokeListtempall2.get(inttemp3));
//将取到的牌置为利用形态
//((DataPoke)pokeListtempall2.get(inttemp3)).setuserFlag(true);
//inttemp4=inttemp3;
//}
//session.setAttribute("pokepc",pokeListtempPC);//拔出电脑失掉的牌到用户的session中
//session.setAttribute("poketotal",pokeListtempall2);//更新总牌
try{
Thread.sleep(30);
}catch(Exceptionex){
ex.printStackTrace();
}

}
publicvoidgetFirstPaipc(PageContextpagecontext)
{
HttpSessionsession=pagecontext.getSession();
//LinkedListpokeListtempuser=newLinkedList();
LinkedListpokeListtempPC=(LinkedList)session.getAttribute("pokepc");
pokeListtempPC.clear();
//先从52张点数牌中随机抽取4张,分离为玩家的两张和农户的两张
//intinttemp1=0;
//intinttemp2=0;
//先将总牌掏出
//paiSession
//LinkedListpokeListtempall1=(LinkedList)session.getAttribute("poketotal");

//给玩家的牌
//for(inti=0;i<2;i++){//从两头取2张牌给玩家
//inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数1
//while(inttemp2==inttemp1&&(((DataPoke)pokeListtempall1.get(inttemp1)).getuserFlag()))//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp1=(int)(Math.random()*100)%51;
//pokeListtempuser.add(i,pokeListtempall1.get(inttemp1));
//将取到的牌置为利用形态
//((DataPoke)pokeListtempall1.get(inttemp1)).setuserFlag(true);
//inttemp2=inttemp1;
//}
//session.setAttribute("pokeuser",pokeListtempuser);//拔出用户失掉的牌到用户的session中
//session.setAttribute("poketotal",pokeListtempall1);//更新总牌
//再将总牌掏出
LinkedListpokeListtempall=(LinkedList)session.getAttribute("poketotal");

intinttemp1=0;
intinttemp2=0;
while(inttemp1==inttemp2||
((DataPoke)pokeListtempall.get(inttemp1)).getuserFlag()==true||
((DataPoke)pokeListtempall.get(inttemp2)).getuserFlag()==true)
{
inttemp1=(int)(Math.random()*100)%51;//取1-52之间的随机数
inttemp2=(int)(Math.random()*100)%51;
}
pokeListtempPC.add(pokeListtempall.get(inttemp1));
pokeListtempPC.add(pokeListtempall.get(inttemp2));
((DataPoke)pokeListtempall.get(inttemp1)).setuserFlag(true);
((DataPoke)pokeListtempall.get(inttemp2)).setuserFlag(true);

//从取后的牌中再取2张给电脑

//for(inti=0;i<2;i++){//从取后的总牌中再取2张牌给电脑
//inttemp3=(int)(Math.random()*100)%51;//取1-52之间的随机数1
//while(inttemp4==inttemp3&&(((DataPoke)pokeListtempall2.get(inttemp3)).getuserFlag())==true)//假如呈现反复的随机数大概该牌已被取,从头取
//inttemp3=(int)(Math.random()*100)%51;
//pokeListtempPC.add(pokeListtempall2.get(inttemp3));
//System.out.println("给电脑的牌的地点:"+((DataPoke)pokeListtempall2.get(inttemp3)).getImgPath());
//System.out.println("给电脑的牌的牌面点数:"+((DataPoke)pokeListtempall2.get(inttemp3)).getpokeFace());

//将取到的牌置为利用形态
//((DataPoke)pokeListtempall2.get(inttemp3)).setuserFlag(true);
//inttemp4=inttemp3;
//}
session.setAttribute("pokepc",pokeListtempPC);//拔出电脑失掉的牌到用户的session中
session.setAttribute("poketotal",pokeListtempall);//更新总牌
try{
Thread.sleep(30);
}catch(Exceptionex){
ex.printStackTrace();
}

}

}





但是我同意你的观点,对于大型项目来说,应该是采用框架的一部分,根据功能的不同而改进,欢迎你能再提出些宝贵意见,我会多多学习的。说到jbuilder,我可能是个人感觉,用的时候确实没有vs爽,我最喜欢的IDE是netbeans,谢谢。
柔情似水 该用户已被删除
沙发
发表于 2015-1-21 07:04:17 | 只看该作者
应用在电视机、电话、闹钟、烤面包机等家用电器的控制和通信。由于这些智能化家电的市场需求没有预期的高,Sun公司放弃了该项计划。随着1990年代互联网的发展
蒙在股里 该用户已被删除
板凳
发表于 2015-1-25 12:00:01 | 只看该作者
不过,每次的执行编译后的字节码需要消耗一定的时间,这同时也在一定程度上降低了 Java 程序的运行效率。
第二个灵魂 该用户已被删除
地板
发表于 2015-1-26 23:07:56 | 只看该作者
Pet Store.(宠物店)是SUN公司为了演示其J2EE编程规范而推出的开放源码的程序,应该很具有权威性,想学J2EE和EJB的朋友不要 错过了。
兰色精灵 该用户已被删除
5#
发表于 2015-2-4 21:22:31 | 只看该作者
是一种将安全性(Security)列为第一优先考虑的语言
不帅 该用户已被删除
6#
发表于 2015-2-9 23:30:38 | 只看该作者
是一种由美国SUN计算机公司(Sun Microsystems, Inc.)所研究而成的语言
山那边是海 该用户已被删除
7#
发表于 2015-2-28 06:42:18 | 只看该作者
你一定会高兴地说,哈哈,原来成为Java高手就这么简单啊!记得Tomjava也曾碰到过一个项目经理,号称Java很简单,只要三个月就可以学会。
飘飘悠悠 该用户已被删除
8#
发表于 2015-3-6 15:08:37 | 只看该作者
有时间再研究一下MVC结构(把Model-View-Control分离开的设计思想)
莫相离 该用户已被删除
9#
发表于 2015-3-10 07:05:17 | 只看该作者
至于JDBC,就不用我多说了,你如果用java编过存取数据库的程序,就应该很熟悉。还有,如果你要用Java编发送电子邮件的程序,你就得看看Javamail 了。
精灵巫婆 该用户已被删除
10#
发表于 2015-3-11 14:44:48 | 只看该作者
我大二,Java也只学了一年,觉得还是看thinking in java好,有能力的话看英文原版(中文版翻的不怎么好),还能提高英文文档阅读能力。
变相怪杰 该用户已被删除
11#
发表于 2015-3-18 20:06:47 | 只看该作者
至于JDBC,就不用我多说了,你如果用java编过存取数据库的程序,就应该很熟悉。还有,如果你要用Java编发送电子邮件的程序,你就得看看Javamail 了。
简单生活 该用户已被删除
12#
发表于 2015-3-25 13:47:55 | 只看该作者
是一种由美国SUN计算机公司(Sun Microsystems, Inc.)所研究而成的语言
只想知道 该用户已被删除
13#
发表于 2015-3-25 15:38:54 | 只看该作者
任职于太阳微系统的詹姆斯·高斯林等人于1990年代初开发Java语言的雏形,最初被命名为Oak,目标设置在家用电器等小型系统的程序语言
活着的死人 该用户已被删除
14#
发表于 2015-3-27 04:09:25 | 只看该作者
Java 不同于一般的编译执行计算机语言和解释执行计算机语言。它首先将源代码编译成二进制字节码(bytecode),然后依赖各种不同平台上的虚拟机来解释执行字节码。从而实现了“一次编译、到处执行”的跨平台特性。
冷月葬花魂 该用户已被删除
15#
发表于 2015-4-12 12:06:34 | 只看该作者
你快去找一份Java的编程工作来做吧(如果是在校学生可以去做兼职啊),在实践中提高自己,那才是最快的。不过你得祈祷在公司里碰到一个高手,而且他 还愿意不厌其烦地教你,这样好象有点难哦!还有一个办法就是读开放源码的程序了。我们知道开放源码大都出自高手,他们设计合理,考虑周到,再加上有广大的程序员参与,代码的价值自然是字字珠叽,铿锵有力(对不起,偶最近《金装四大才子》看多了)。
因胸联盟 该用户已被删除
16#
发表于 2015-4-12 17:09:47 | 只看该作者
Sun公司看见Oak在互联网上应用的前景,于是改造了Oak,于1995年5月以Java的名称正式发布。Java伴随着互联网的迅猛发展而发展,逐渐成为重要的网络编程语言。
小魔女 该用户已被删除
17#
发表于 2015-4-21 20:12:07 | 只看该作者
Java语言支持Internet应用的开发,在基本的Java应用编程接口中有一个网络应用编程接口(java net),它提供了用于网络应用编程的类库,包括URL、URLConnection、Socket、ServerSocket等。Java的RMI(远程方法激活)机制也是开发分布式应用的重要手段。
飘灵儿 该用户已被删除
18#
 楼主| 发表于 2015-4-24 18:06:50 | 只看该作者
当然你也可以参加一些开源项目,一方面可以提高自己,另一方面也是为中国软件事业做贡献嘛!开发者在互联网上用CVS合作开发,用QQ,MSN,E-mail讨论联系,天南海北的程序员分散在各地却同时开发同一个软件,是不是很有意思呢?
小女巫 该用户已被删除
19#
发表于 2015-4-30 12:26:05 | 只看该作者
是一种语言,用以产生「小应用程序(Applet(s))
再现理想 该用户已被删除
20#
发表于 2015-5-4 07:05:45 | 只看该作者
还好,SUN提供了Javabean可以把你的JSP中的 Java代码封装起来,便于调用也便于重用。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-25 23:50

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表