Question: 1) Write a class , Point, to represent a 2-dimensional point with coordinates x and y (both doubles). Your class should contain the following instance

 1) Write a class , Point, to represent a 2-dimensional point

with coordinates x and y (both doubles). Your class should contain the

1) Write a class , Point, to represent a 2-dimensional point with coordinates x and y (both doubles). Your class should contain the following instance variables and methods, override toString() and equals(), and implement the comparable interface. private double x private double y public Point () public Point (double x, double y) public void setx (double x) public void sety (double y) public double getX() public double getY() public double distance (Point p) the x coordinate the y coordinate constructs the point(0, 0) constructs a point with the given coordinates sets the x coordinate to the given value sets the y coordinate to the given value returns the x coordinate returns the y coordinate returns the distance from another point Two points are equal if they have the same x coordinates and the same y coordinates. When implementing Comparable, points should be compared relative to their distance from the origin (0,0), with points closer to the origin considered less than points farther from it. The distance between two points is defined as the square root of the sum of the squares of the differences between the x and y coordinates. Below is the distance formaula: d= (x2 21)2 + (y2 y)2 Use Javadoc comments including @param and @return. Your answer 2) Consider the point class you wrote in question #1. The following code produces 4 lines of output. Write each line of output below as it would appear on the screen. public class Question2 { public static void main (String[] args) { int a = 3; int b = 6; Point pl = new Point (2,2); Point p2 = new Point (2,2); addTwice (a, pl); System.out.println(a + + pl.getX() addTwice (b, p2); System.out.println(a + + pl.getX() + "" } + 1 + p2.getX()); TI 11 + p2.getX()); public static void addTwice (int a, Point pl) { a = a + a; p1.setX (a); System.out.println(a + + pi.getX(); } } Your

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!