JAVA打字游戏源码.doc_第1页
JAVA打字游戏源码.doc_第2页
JAVA打字游戏源码.doc_第3页
JAVA打字游戏源码.doc_第4页
JAVA打字游戏源码.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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();Random 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.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.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 getStrLength() 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 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.strLength = 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, 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;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 setStartTime(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 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.pr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论