各位大神 猜数字游戏为什么我输入继续 它却退出? 求解
import java.util.*;public class Guessdigital{
public static void main(String[] args){
Scanner digital = new Scanner(System.in);
System.out.println("欢迎玩猜数字游戏!");
System.out.println("每局您将有三次机会");
System.out.println("当局结束您可以按go继续,按quit退出");
int number = 1;
String choose = "";
double rand = Math.random()*100;
int random = (int)rand;
//System.out.println("random = "+random);产生的随机数
System.out.println("请输入数字");
int j = digital.nextInt();
System.out.println(" "+j);
do{
if(j == random&&number <= 10)
{ System.out.println("恭喜你猜对了!");
System.out.println("请选择是否继续?Y or yes - 继续 N or no - 退出!"); //就是这里!!!!我输入Y or yes 它就输出“欢迎下次继续来玩”
choose = digital.next();
if(choose == "Y"||choose == "yes")
{ rand = Math.random()*100;
random = (int)rand;
number = 1;
// System.out.println("random = "+random);产生的随机数
System.out.println("请输入数字");
j = digital.nextInt();
number++;
System.out.println(""+j);
return;
}
else
{
System.out.println("欢迎下次继续来玩");
break;
}
}
else if(j > random&&number < 10)
{
System.out.println("输入数字过大,请重新输入");
j = digital.nextInt();
number++;
continue;
}
else if(j < random&&number < 10)
{
System.out.println("输入数字过小,请重新输入");
j =digital.nextInt();
number++;
continue;
}
else if(j!=random&&number == 10)
{
System.out.println("Game over!\n请选择是否继续?go - 继续 任意键 - 退出!");
choose = digital.next();
if(choose == "go")
{ rand = Math.random()*100;
random = (int)rand;
number = 1;
// System.out.println("random = "+random);产生的随机数
System.out.println("请输入数字");
j = digital.nextInt();
number++;
System.out.println(""+j);
return;
}
else break;
}
}while(choose == "Y"||choose == "yes"||number <= 10);
}
}