Question: I 10. Create a Point class that implements Comparable Interface and has two data members x and y of double type. Write a default constructor

 I 10. Create a Point class that implements Comparable Interface and

I 10. Create a Point class that implements Comparable Interface and has two data members x and y of double type. Write a default constructor which initializes its data members to zero. Write a parameterized constructor which takes two parameters of double type and assigns them to its data members. Write another parameterized constructor that takes one Point object as parameter and copies the values of the passed object's data member to the calling object's data members. Write a find_distance method that takes two double parameters representing the x, y values of a point and finds the distance between the calling object and the passed parameters and returns the distance as double value. Overload the find distance method, that takes single Point object parameter and computes the distance between both the points and returns the distance as a double value. Define the compare To method that returns difference between the distances of the two points from origin. Write a display method to print the point in the format of "(x, y)". In main method create a HashSet objects. Create and add 10 Point objects in the HashSet. Display the points in the ascending order of the points based on the distance from the origin to that point. Also find distance between every pair of points and display it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!