我正在尝试获取用户输入,但是我正在
illegal start of expression
:
public static String askTheUser() throws IOException
完整代码:
编辑:我已经做了你们建议的大部分更改,所以现在我有了这个:
import java.io.BufferedReader;
public class Driver
{
public static void main(String[]args)
{
Dice dice;
Craps craps;
userResponse = askTheUser();
while(userResponse.equalsIgnoreCase("yes"))
{
craps = new Craps();
while(!craps.gameOver())
{
craps.roll();
//print out results of roll
}
//print out game results: if(craps.gameWon()...
userResponse.askTheUser();
}
}
public static String askTheUser() throws IOException
{
BufferedReader dataIn = new BufferedReader( new InputStreamReader(System.in) );
String data;
System.out.print("Want to play craps? Yes or No");
data = dataIn.readLine();
if(data.equals("y") || data.equals("yes"))
{
return "yes";
}
else
{
return "no";
}
}
}
但是我仍然cannot find symbol
在public static String askTheUser() throws IOException
. 那么我可能会错过一个我不知道的进口吗?