Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions