JAVA打字游戏源码.pdf

上传人:索**** 文档编号:76248050 上传时间:2023-03-08 格式:PDF 页数:7 大小:8.59KB
返回 下载 相关 举报
JAVA打字游戏源码.pdf_第1页
第1页 / 共7页
JAVA打字游戏源码.pdf_第2页
第2页 / 共7页
点击查看更多>>
资源描述

《JAVA打字游戏源码.pdf》由会员分享,可在线阅读,更多相关《JAVA打字游戏源码.pdf(7页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、package com.xt.game.entrty;import java.util.Random;public class Game Player player;public Game(Player player)this.player=player;/*输出字符*param strLength*return*/public String printStr()int strLength=player.getLevelNo();Level level=LevelParam.levelsstrLength-1;StringBuffer buffer=new StringBuffer();Ran

2、dom random=new Random();for(int i=0;i LevelParam.levelsplayer.getLevelNo()-1.getTimeLimit()System.out.println(游戏超时,闯关失败!);System.exit(1);else player.setCurScore(player.getCurScore()+LevelParam.levelsplayer.getLevelNo()-1.getPerScore();System.out.println(输入正确,您的积分是+player.getCurScore()+分,您的级别是+player

3、.getLevelNo()+级,您所用时间+(currentTime-player.getStartTime()/1000+秒);if(player.getLevelNo()=6)int score=LevelParam.levelsplayer.getLevelNo()-1.getPerScore()*LevelParam.levelsplayer.getLevelNo()-1.getStrTimes();/计算闯关分数if(player.getCurScore()=score)System.out.println(闯关成功!);System.exit(0);else System.out.

4、println(输入错误,闯关失败!);System.exit(1);package com.xt.game.entrty;public class Level private int levelno;private int strLength;private int strTimes;private int timeLimit;private int perScore;public int getLevelno()return levelno;public void setLevelno(int levelno)this.levelno=levelno;public int getStrLe

5、ngth()return strLength;public void setStrLength(int strLength)this.strLength=strLength;public int getStrTimes()return strTimes;public void setStrTimes(int strTimes)this.strTimes=strTimes;public int getTimeLimit()return timeLimit;public void setTimeLimit(int timeLimit)this.timeLimit=timeLimit;public

6、int getPerScore()return perScore;public void setPerScore(int perScore)this.perScore=perScore;/*Level 构造方法*param levelno*param strLength*param strTimes*param timeLimit*param perScore*/public Level(int levelno,int strLength,int strTimes,int timeLimit,int perScore)super();this.levelno=levelno;this.strL

7、ength=strLength;this.strTimes=strTimes;this.timeLimit=timeLimit;this.perScore=perScore;package com.xt.game.entrty;/*数组*author Administrator*/public class LevelParam public final static Level levels=new Level9;static levels0=new Level(1,2,10,30,1);levels1=new Level(2,3,9,28,2);levels2=new Level(3,4,8

8、,26,5);levels3=new Level(4,5,7,24,8);levels4=new Level(5,6,6,22,10);levels5=new Level(6,7,5,20,15);levels6=new Level(7,8,4,18,20);levels7=new Level(8,9,3,16,25);levels8=new Level(9,10,2,14,30);package com.xt.game.entrty;import java.util.*;public class Player private int levelNo;private int curScore;

9、private long startTime;private int elapsedTime;public int getLevelNo()return levelNo;public void setLevelNo(int levelNo)this.levelNo=levelNo;public int getCurScore()return curScore;public void setCurScore(int curScore)this.curScore=curScore;public long getStartTime()return startTime;public void setS

10、tartTime(long startTime)this.startTime=startTime;public int getElapsedTime()return elapsedTime;public void setElapsedTime(int elapsedTime)this.elapsedTime=elapsedTime;/*游戏*/public void play()Scanner input=new Scanner(System.in);Game game=new Game(this);System.out.println(t 九九数字打字速度测试);for(int i=0;i

11、LevelParam.levels.length;i+)System.out.println(t-);System.out.println(t|t第+(i+1)+关t|);System.out.println(t-);this.setLevelNo(getLevelNo()+1);this.setStartTime(System.currentTimeMillis();this.setCurScore(0);for(int j=0;j LevelParam.levelslevelNo-1.getStrTimes();j+)String out=game.printStr();System.out.println(out);String in=input.next();game.printResult(out,in);package com.xt.game.test;import com.xt.game.entrty.*;public class Test /*param args*/public static void main(String args)Player player=new Player();player.play();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 实施方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com