我正在尝试创建一个菜单,其中有四个选项:
这是我到目前为止所做的:
import easyIO.*;
class Menu {
public static void main(String[] args) {
int counter = 0;
while (counter != 4) {
counter = meny();
switch (counter) {
case 1:
ReigsterBird(1);
break;
case 2:
WriteBirdType(2);
break;
case 3:
WritePlace(3);
break;
case 4:
break;
default:
System.out.println("Give a number between 1 and 4");
}
}
}
但我一直在收到这些错误,而且我也不确定如何解决这个问题。有什么我想念的吗?
Menu.java:9: error: cannot find symbol
counter = meny();
^
symbol: method meny()
location: class Menu
loop.java:13: error: cannot find symbol
ReigsterBird(1);
^
symbol: method ReigsterBird(int)
location: class Menu
Menu.java:16: error: cannot find symbol
WriteBirdType(2);
^
symbol: method WriteBirdType(int)
location: class Menu
loop.java:19: error: cannot find symbol
WritePlace(3);
^
symbol: method WritePlace(int)
location: class Menu
4 errors
如果有人可以提供帮助,我将不胜感激,因此我可以创建一个菜单,您可以从中选择四个选项。
答案 0 :(得分:2)
您需要添加方法。我知道这对初学者来说很困惑,所以这就是它的样子:
import easyIO.*;
class Menu {
public static void main(String[] args) {
...
}
public static int meny() {
...
}
public static void ReigsterBird(int x) {
...
}
}