我是java的新手,我正在努力理解基础知识。因此,我无法理解为什么这不会编译。
错误出现在int guess = input.guess();
上,它表示无法找到符号 - 方法guess()。
提前感谢您提供任何帮助
public class HiLo
{
private int upper;
private int randomNumber;
private Input input;
private boolean won;
private int guesses;
public HiLo(int x)
{
upper = x-1;
randomNumber = (int)(Math.random() * upper)+1;
input = new Input();
won = false;
guesses = 10;
}
public void playHumanGame()
{
while ((won == false) && (guesses > 0))
{
int guess = input.guess();
guesses--;
if (guess > randomNumber)
{
System.out.println("You're too high pal");
}
else if (guess < randomNumber)
{
System.out.println("You're not high enough");
}
else
{
System.out.println("You won the game... Well done I suppose...");
won = true;
}
}
}
}