Question: java Task4: A Class called MyPoint, which models a 2D point with x and y coordinates, is designed as shown in the class diagram. MyPoint

java java Task4: A Class called MyPoint, which models a 2D point with

Task4: A Class called MyPoint, which models a 2D point with x and y coordinates, is designed as shown in the class diagram. MyPoint -x:int - yaint- HyPoint() -MyPoint(int, y:int) getX(): int setxixint) void etY()int setyy:int) vold sexy(x: int, y:int):void toString():String distance(int, yrint) double -distance another Wypoint):double It contains a Two instance variables x (int) and y(int). b. A'no-argument" (or "no-arg") constructor that construct a point at (0,0). c. A constructor that constructs a point with the given x and y coordinates. d. Getter and setter for the instance variables x and y e. A method setXY to set both x and y. A toString() method that returns a string description of the instance in the format "IX. y 9. A method called distance (int x, int y) that returns the distance from this point to another point at the given (x, y) coordinates h. An overloaded distance (MyPoint another) that returns the distance from this point to the given MyPoint instance another. Write a test application MyPointTest and perform the followings. a. Create two objects for the class MyPoint. b. Test the overloaded distance methods and display the distance between the two points Sample Output: Inter lat point x - coordinate: Enter lat point y - coordinate :: 5 Enter and point x - coordinate :: Enter and point y - coordinate: 2 Distance (7,5), (3, 2)) with tizat object - 5.00 Enter 1st point x - coordinate: 30 Enter 1st point y coordinate :: Distance (7,5). (20,4)) with 2nd object = 4.24

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!