Dear all ,
I have the following UML Diagram and below the associated Code. Can you please help me complete the code?
Thanks in advance
I have written my UML diagram as follows.
-x : double
-y : double
+MyPoint()
+MyPoint(x:double,y:double)
+get X() :double
+getY() : double
+distance: (MyPoint1:MyPoint2):double
+distance(p1:MyPoint:p2:MyPoint):double
My code is the following and I am missing the last two methods
import java.lang.Math
public class MyPoint {
private double x,y, distance;
public MyPoint(){
x=0;
y=0; // assign zero to the attribute y.
}
public MyPoint(double x, double y){
this.x=x;
this.y=y;
}
public getX(double x){
return x;
}
public getY(double y){
return y;
}
public double distance (MyPoint1 , MyPoint2){
// distance =
}
public static void main(String []args)
{
MyPoint MyPoint1 = new MyPoint();
MyPoint MyPoint2 = new MyPoint(10, 30.5);
}
}//end of class