方法如下:
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 应该使用哪种策略?(#)”,它只是尝试从键盘获取输入。为什么要这样做?
最佳答案
while () *;*
没有执行您想要的操作,请删除分号。
顺便说一句,任何像样的 java 编译器都会警告你这一点,你读过它告诉你的内容吗?
关于java - 为什么这个方法不打印它的文本? (java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2557391/