package com.bjsxt.test2;
import org.w3c.dom.ls.LSOutput;
class Point {
double x,y;
public Point(double _x, double _y){
x = _x;
y = _y;
}
public double getDistance(Point p){
return Math.sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
}
}
public class TestConstructor {
public static void main(String[] args) {
Point p = new Point(3.0,4.0);
Point origin = new Point(0.0,0.0);
System.out.println(p.getDistance(origin));
}
}
日常练习
最新推荐文章于 2024-08-01 15:05:06 发布