package type_Game;
import java.util.Scanner;
public class Player {
private int rank;//当前级别
private int currScore;//分数
// private String startTime;//开始时间
// private String elapseTime;//所用时间
public Player () {}
public Player(int rank, int currScore) {
super();
this.rank = rank;
this.currScore = currScore;
// this.startTime = startTime;
// this.elapseTime = elapseTime;
}
public void Score() {
int flag = 1;
String s = "";
Scanner sc = new Scanner(System.in);
while(flag == 1 && this.rank < 7) {
for (int i = 0;i<rank;i++){
s += (char)(Math.random()*26+'A');//随等级的增加 增加字母数量
}
System.out.println("*******请输入和下面相同的字符********");
System.out.println("*******" + s + "********");
long startTime=System.currentTimeMillis(); //获取开始时间
String a = sc.next();
long endTime=System.currentTimeMillis(); //获取结束时间
if (s.equals(a)) { //判断字母与输入的字符是否相等,相等则进入循环,加分进入下一个等级
this.currScore = this.currScore + 10 ;
System.out.println("*******输入正确,你的分数为"+this.currScore+"您的级别为"+this.rank);
System.out.println("*******所用时间为" + (endTime - startTime) /1000 + "秒");
this.rank++;//等级+1
flag = 1;//表示没有输入错误,循环继续
s = "";//清空字符串s
if (this.rank > 6) {
System.out.println("*******恭喜你,你的手速已经天下无敌了,没人比得过你,你已通关!!!!!!!!!");
}
}else if(!s.equals(a)) {
System.out.println("**********对不起你输入错误,游戏结束!!!!********");
flag = 0;//表示输入错误,循环结束
}
}
}
}