Question: Add a new method to the Point class we developed in this chapter: public double distance(Point other) Returns the distance between the current Point object

Add a new method to the Point class we developed in this chapter:

public double distance(Point other)

Returns the distance between the current Point object and the given other Point object. The distance between two points is equal to the square root of the sum of the squares of the differences of their x- and y-coordinates In other words, the distance between two points (x1, y1) and (x2, y2) can be expressed as the square root of (x2 − x1)2 and (y2 − y1)2. Two points with the same (x, y) coordinates should return a distance of 0.0.

Step by Step Solution

3.41 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Returns the distance from this p... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!