Question: Write the code for a class named Point to represent a point in the Cc rtesian plane with x and y coordinates. The class contains

Write the code for a class named Point to represent a point in the Cc rtesian plane with x and y coordinates. The class contains . Two instance variables x and y that represent the coordinates with getX0 and getYO method e A constructor that constructs a point with specified coordinates, with default values 0 and 0 . An str method to return a string representation in the form (x, y) . A method named distance that returns the distance from this point to another point. The formula for finding the distance between A method named originDistance that returns the distance from this point to the point of origin (0,0). the two points (xl.y1) and (x2, y2) is math sqrt(x2- xl)? + (y2-yl)2) Appropriate code so that points can be compared using the comparison operators. Points are compared based on their distance from the origin Add a test program that does the following e Creates a point object, named pO, that uses the default values for the coordinates. Print p . Creates a point object, named pl, with coordnates at (3,4) Print pl Creates a pont ob ect, named p2, with coordinates at 3,0 When creating the o ect, take advantage of the act that the value ofthe v ccordinate s the default value of the corresponding parameter. e Print the x and y coordinates of p2 using the getXO and getYO methods e Find and print the distance between pl and p2 Print the results of comparing pl and p2. Make sure to test all 6 comparison operators. . Your code should allow using and ! to compare a Point object with an object of a different type. Print the result of using the equality and inequality operators to compare pl with the string "Hello
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
