Question: Design a class named Point to represent a point with x - and y - coordinates. The class contains: Two private data fields x and

Design a class named Point to represent a point with x- and y-coordinates. The class contains:
Two private data fields x and y represent the coordinates with getter methods.
A constructor that constructs a point with specified coordinates, with default (0,0)
A method named isNearBy(p1) returns True if point p1 is close to this point.
Two points are close if their distance is less than 5.
Note: distance between two points can be calculated using: square root of left parenthesis y subscript 2 minus y subscript 1 right parenthesis squared plus left parenthesis x subscript 2 minus x subscript 1 right parenthesis squared end root
The __str__ method to return a string in the form (x,y)

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 Programming Questions!