Class Self-Reference

10.7k Views Asked by At

I have the following code. The angle function needs some information from the class it was called from. What's the best way to do this?

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?*);
}
1

There are 1 best solutions below

3
On BEST ANSWER

Pass this.

int a = MyScannedRobotEvent.angle(this);

See also: