Question: please write in PYTHON. Thanks (The Point class) Design a class named Point to represent a point with x- and y-coordinates. The class contains: -
please write in PYTHON. Thanks
(The Point class)
Design a class named Point to represent a point with x- and y-coordinates. The class contains:
- Two private data fields x and y that represent the coordinates with get methods. - A constructor that constructs a point with specified coordinates, with default point (0, 0). - A method named distance that returns the distance from this point to another point of the Pointtype. - A method named isNearBy(p1) that returns true if point p1 is close to this point. Two points are close if their distance is less than 5. - Implement the __str__ method to return a string in the form (x, y). Draw the UML diagram for the class, and then implement the class. Write a test program that prompts the user to enter two points, displays the distance between them, and indicates whether they are near each other.
Sample Run:
Enter the x-coordinate of point1: 2.1
Enter the y-coordinate of point1: 2.3
Enter the x-coordinate of point2: 19.1
Enter the y-coordinate of point2: 19.2
The distance between the two points is 23.97
The two points are not near each other
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
