我正在尝试为游戏中的对象定义一些属性,因此我使用接口来指定它们。
我已经创建了一个Interactable
接口,但是后来我想创建一个Eatable
接口,这显然是Interactable
因为交互是为了吃饭,但我不能这样做,因为我无法在接口中实现一个方法。
有解决方法吗?
public interface Interactable {
void interact();
}
public interface Eatable implements Interactable {
public void eat();
public void interact() {
// Obviously, this doesn't work
eat();
}
}