Java methods getting euclidean distance

Your method returns a Point because you return result which is an instance of Point. If you want a double (value) for the distance you should do it this way:

//euclidean distance (?)
double distance (Point other) {
    Point result = new Point(); 
    result.ycoord = Math.abs (ycoord - other.ycoord);
    result.xcoord = Math.abs (xcoord- other.xcoord);    
    result.distance = Math.sqrt((result.ycoord)*(result.ycoord) +(result.xcoord)*(result.xcoord));
    return result.distance; 

Leave a Comment