I'm programming Robocode and now I have a coding question:
I defined class Enemy
to store enemy information (such as heading, bearing, velocity etc.) and in this class I also defined a private attribute named direction. Then I use the public getters and setters to allow my bot to call those properties. But when I use enemy.setDirection(e.getDirection());
, NetBean IDE shows it as incorrect. Could someone help solve this problem?
public class Enemy {
// ...
private double direction;
public double getDirection(ScannedRobotEvent e, AdvancedRobot me) {
direction = e.getBearing() + me.getHeading();
return direction;
}
public void setDirection(double direction) {
this.direction = direction;
}
}
Then in my robot class:
public class myBot extends AdvancedRobot {
private Enemy enemy = new Enemy();
public onScannedRobot(ScannedRobotEvent e) {
enemy.setDirection(e.getDirection()); // Here is the problem
}
}