public class Solution {
public static void main(String[] args) throws Exception {
//main 方法必须从键盘读取字符串
Person person = null;
String key = null;
while (true) {
key = reader.readLine();
if (!(key.equals("user") || key.equals("loser") || key.equals("coder") || key.equals("programmer")))
/*
补全代码
//读取任何与上述内容不匹配的字符串后停止读取。
*/
}
}
public static void doWork(Person person) {
/*
补全代码
调用 doNothing() 方法(如果人是 Loser)。
调用 writeCode() 方法(如果人是 Coder)。
调用 enjoy() 方法(如果人是 Programmer)
*/
}
}
尝试了多种方法,解不出,还在尝试。
过程中主要是给定的代码key = reader.readLine();这一行代码,频繁报错error: cannot find symbol,也试过换成Scanner但是也不行,求帮助。
然后这个Person是接口,怎么在所传递的对象上调用方法?