展开全部
public static void main(String[] args) {
final String[] tips = { "智商636f70793231313335323631343130323136353331333363373834200+", "智商180+", "智商140+", "智商100+", "低能80" };
final int NUM = 5;
int result = 0;
int step = 0;
int RANDOMS = 0;
while (true) {
RANDOMS = new Random().nextInt(50) + 1;
// System.out.println("RANDOMS = " + RANDOMS);
System.out.print("请猜一个数,范围在0-50:");
step = 0;
while (step
result = new Scanner(System.in).nextInt();
if (result > RANDOMS) {
if (step
System.out.println("抱歉,你猜的数字有点大哦,要不再试一次?");
}
} else if (result
if (step
System.out.println("抱歉,你猜的数字有点小咯,要不再次一次?");
}
} else {
System.err.println("太棒了,你猜对了!" + tips[step]);
break;
}
step++;
}
if (step == 5) {
System.out.println("抱歉,你猜的次数已经超过限制!");
}
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (true) {
System.out.print("大侠,要不要再来一次(y/n)?");
String ys = new Scanner(System.in).next();
if (ys.startsWith("y") || ys.startsWith("Y")) {
System.out.println("游戏重新开始...");
break;
} else if (ys.startsWith("n") || ys.startsWith("N")) {
System.out.println("游戏结束...");
return;
}
}
}
}