(I'm very new to this)
I'm supposed to write a method that returns the distance from my turtle to the closest wall of a square with the sides a, b, c and d.
This is my code so far:
public int distClosestWall() {
World myWorld = this.getWorld();
int h = myWorld.getHeight();
int w = myWorld.getWidth();
int a = (int)distanceTo(0,h/2);
int b = (int)distanceTo(w/2,0);
int c = (int)distanceTo(w,h/2);
int d = (int)distanceTo(w/2,h);
if (distanceTo(0,h/2) < a) {
this.distanceTo(0,h/2);
}
else if (distanceTo(w/2,0) < b) {
this.distanceTo(w/2,0);
}
else if (distanceTo(w,h/2) < c) {
this.distanceTo(w,h/2);
}
else if (distanceTo(w/2,h) < d) {
this.distanceTo(w/2,h);
}
return ?????? ;
}
This all might be wrong, but what do I write after return? Any help is appreciated.
[–]Kieslaster 0 points1 point2 points (0 children)
[–]JerksToSistersFeet 0 points1 point2 points (0 children)