求用JAVA程序编一个有窗口的猜字小游戏紧急!!!有注释最好!!!回答的好的话加分咯!!!

2024-11-28 11:51:58
推荐回答(1个)
回答(1):

import java.io.*;
import java.io.BufferedWriter;

public class GuessNumber {
public void show() {
DataInputStream stdin = new DataInputStream(System.in);
BufferedInputStream buffin = new BufferedInputStream(stdin);
number = (int) (Math.random() * 100);
try {
while (flag) {
input = stdin.readLine();
guessnumber = Integer.parseInt(input);
{
if (number < guessnumber)
{
after=guessnumber;
System.out.println("你输入的数大了,请重新输入:");
System.out.print("输入从"+before+"到"+after+"之间的数");
}
if (number > guessnumber)
{ before=guessnumber;
System.out.println("你输入的数小了,请重新输入:");
System.out.print("输入从"+before+"到"+after+"之间的数");
}
count++;
flag = true;
}
if (number == guessnumber) {
System.out.println("你真历害这么快你就猜对了!");
System.out.println("你一共猜了" + count + "次");
flag = false;
System.out.println("请输入你的名字:");
String name = stdin.readLine();
byte names[] = name.getBytes("ISO-8859-1");
userName = new String(names);
System.out.println("姓名:" + userName);
System.out.println("记录是:" + count + "次");
SaveFile save = new SaveFile();
save.output(userName, 0, userName.length());
}
}
stdin.close();
buffin.close();
}
catch (IOException e) {
e.getMessage();
System.out.println("产生了异常!");
}
}
贴不下全部代码..+二七四二三三六七二