We want to write a Robocode method called distanceTo that gives us the distance from our robot to a set of x and y coordinates. The start of distanceTo is as follows:
/* * distanceTo: compute and return distance to a set of x,y coordinates * * inputs: double x, double y * output: return double distance from our robot to x, y */ public double distanceTo( double x, double y )
Define and test the distanceTo method in MethodBot1.
Note: We've calculated distance between x,y coordinates before in AdjustFireBot2 and CenterBot3.