现在代码是在5以内的数任取一个猜,问题是如何实现重新开始怎么我的dowhile没用?publicstaticvoidmain(String[]args)throwsIOException{//TODOcodeapplicationlogichereintx;inta;bo...
现在代码是 在5以内的数任取一个猜,问题是如何实现 重新开始
怎么我的do while没用?
public static void main(String[] args) throws IOException {
// TODO code application logic here
int x;
int a;
boolean again=false;
x=(int)(Math.random()*(5-0)+0);
System.out.println("GOGO,猜猜我是谁!");
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
a: do
{
for(int i=0; ;i++)
{
String z=b.readLine();
a=Integer.parseInt(z);
if(a>x)
{
System.out.println("真可惜.太大了");
continue;
}
else if(a
{ System.out.println("可惜,小了点..");
continue;
}
else if(a==x)
{
System.out.println("恭喜你,"+(i+1)+"猜对了0 0");
break;
}
}
System.out.println("是否重新开始(y/n)?");
String z=b.readLine();
again=z.equalsIgnoreCase("y")?true:false;
} while(again=false);
//if(again=false)
System.out.println("欢迎使用");
不行哦..我改成again==flase还是不能重新开始,不能重新循环~
我改成 again!=flase 和用while(true)都不行哦..输入Y或者N都没任何反映?
奇怪哦~~
展开