我有一个关于java继承的小问题。所以说我有以下课程。
class ScreenObject {
public void update(GameContainer gc, StateBasedGame sbg, int delta) {
Input input = gc.getInput();
int mouseX = input.getMouseX();
int mouseY = input.getMouseY();
boolean mouseClick = input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON);
if (detectMouseClick(mouseX, mouseY, mouseClick)) {
this.performClick(gc,sbg,delta);
}
}
public void performClick(GameContainer gc, StateBasedGame sbg, int delta) {
}
}
class CrewMember extends ScreenObject {
public void update(GameContainer gc, StateBasedGame sbg, int delta) {
super.update(gc, sbg, delta);
}
public void performClick(GameContainer gc, StateBasedGame sbg, int delta) {
System.out.println("hi");
}
}
现在当crewMember.update()
用正确的参数调用时,没有输出,当应该有“hi”时。