我有以下代码。角度函数需要来自调用它的类的一些信息。做这件事最好的方法是什么?
class MyScannedRobotEvent extends robocode.ScannedRobotEvent {
public int angle(robocode.Robot myRobot) {
return (int) Math.toRadians((myRobot.getHeading() + getBearing()) % 360);
}
}
public class MyRobot extends robocode.Robot {
int a = MyScannedRobotEvent.angle(*WHATDOIPUTHERE?*);
}发布于 2010-12-24 10:51:50
传递this。
int a = MyScannedRobotEvent.angle(this);另请参阅:
this keywordhttps://stackoverflow.com/questions/4523896
复制相似问题