这是方法:
public static int chooseStrat ()
{
String[] strats = new String[1] ;
strats[0] = "0 - Blob" ;
int n ;
boolean a = false ;
while (a == false) ;
{
System.out.println ("Which strategy should the AI use?(#)") ;
printArrayS (strats) ;
n = getInt () ;
System.out.println ("you selected "+n+"."+" are you sure you want the computer to use the "+ strats[n]+ " ?(Y/N)") ;
String c = getIns () ;
while ((((!( (c.equals ("y")) || (c.equals ("Y")) )) && (!( (c.equals ("n")) || (c.equals ("N")) ) ) ))) ;
{
System.out.println ("try again") ;
c = getIns () ;
}
if ( (c.equals ("Y")) || (c.equals ("y")) )
a = true ;
}
return n ;
}
当我运行它时,它从不打印“AI应该使用哪种策略?(#)”它只是试图从键盘输入一个条目。它为什么这样做?
答案 0 :(得分:3)
while () *;*
无法执行您想要的操作,请删除分号。
顺便说一下,任何体面的java编译器都会警告你,你读过它告诉你的内容吗?
答案 1 :(得分:3)
while (a == false) ;
那是一个无限循环。除掉 ;对于初学者来说