欢迎来到天天文库
浏览记录
ID:37852315
大小:43.00 KB
页数:7页
时间:2019-06-01
《JAVA打字游戏源码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、packagecom.xt.game.entrty;importjava.util.Random;publicclassGame{Playerplayer;publicGame(Playerplayer){this.player=player;}/***输出字符**@paramstrLength*@return*/publicStringprintStr(){intstrLength=player.getLevelNo();Levellevel=LevelParam.levels[strLength-1];StringBufferbuffer=newStr
2、ingBuffer();Randomrandom=newRandom();for(inti=0;i3、);break;case5:buffer.append("6");break;case6:buffer.append("7");break;case7:buffer.append("8");break;case8:buffer.append("9");break;}}returnbuffer.toString();}/***字符对比**@paramout*@paramin*/publicvoidprintResult(Stringout,Stringin){if(out.equals(in)){longcurrentTime=System.currentT4、imeMillis();if((currentTime-player.getStartTime())/1000>LevelParam.levels[player.getLevelNo()-1].getTimeLimit()){System.out.println("游戏超时,闯关失败!");System.exit(1);}else{player.setCurScore(player.getCurScore()+LevelParam.levels[player.getLevelNo()-1].getPerScore());System.out.println5、("输入正确,您的积分是"+player.getCurScore()+"分,您的级别是"+player.getLevelNo()+"级,您所用时间"+(currentTime-player.getStartTime())/1000+"秒");if(player.getLevelNo()==6){intscore=LevelParam.levels[player.getLevelNo()-1].getPerScore()*LevelParam.levels[player.getLevelNo()-1].getStrTimes();//计算闯关分数if(pla6、yer.getCurScore()==score){System.out.println("闯关成功!!!");System.exit(0);}}}}else{System.out.println("输入错误,闯关失败!");System.exit(1);}}}packagecom.xt.game.entrty;publicclassLevel{privateintlevelno;privateintstrLength;privateintstrTimes;privateinttimeLimit;privateintperScore;publicintge7、tLevelno(){returnlevelno;}publicvoidsetLevelno(intlevelno){this.levelno=levelno;}publicintgetStrLength(){returnstrLength;}publicvoidsetStrLength(intstrLength){this.strLength=strLength;}publicintgetStrTimes(){returnstrTimes;}publicvoidsetStrTimes(intstrTimes){this.strTimes=strTimes8、;}publicintgetTimeLimit(){returnt
3、);break;case5:buffer.append("6");break;case6:buffer.append("7");break;case7:buffer.append("8");break;case8:buffer.append("9");break;}}returnbuffer.toString();}/***字符对比**@paramout*@paramin*/publicvoidprintResult(Stringout,Stringin){if(out.equals(in)){longcurrentTime=System.currentT
4、imeMillis();if((currentTime-player.getStartTime())/1000>LevelParam.levels[player.getLevelNo()-1].getTimeLimit()){System.out.println("游戏超时,闯关失败!");System.exit(1);}else{player.setCurScore(player.getCurScore()+LevelParam.levels[player.getLevelNo()-1].getPerScore());System.out.println
5、("输入正确,您的积分是"+player.getCurScore()+"分,您的级别是"+player.getLevelNo()+"级,您所用时间"+(currentTime-player.getStartTime())/1000+"秒");if(player.getLevelNo()==6){intscore=LevelParam.levels[player.getLevelNo()-1].getPerScore()*LevelParam.levels[player.getLevelNo()-1].getStrTimes();//计算闯关分数if(pla
6、yer.getCurScore()==score){System.out.println("闯关成功!!!");System.exit(0);}}}}else{System.out.println("输入错误,闯关失败!");System.exit(1);}}}packagecom.xt.game.entrty;publicclassLevel{privateintlevelno;privateintstrLength;privateintstrTimes;privateinttimeLimit;privateintperScore;publicintge
7、tLevelno(){returnlevelno;}publicvoidsetLevelno(intlevelno){this.levelno=levelno;}publicintgetStrLength(){returnstrLength;}publicvoidsetStrLength(intstrLength){this.strLength=strLength;}publicintgetStrTimes(){returnstrTimes;}publicvoidsetStrTimes(intstrTimes){this.strTimes=strTimes
8、;}publicintgetTimeLimit(){returnt
此文档下载收益归作者所有