JAVA 数学计算
package basic.day08; public class Point { int x; int y; public Point(int x,int y){ this.x=x; this.y=y; } public Point(int x){ // this.x=x; // this.y=x; this(x,x); } public double distance(){ return Math.sqrt(this.x*this.x+this.y*this.y); } public double distance(int x,int y){ return Math.sqrt((this.x-x)*(this.x-x)+(this.y-y)*(this.y-y)); } public double distance(Point other){ return Math.sqrt((x-other.x)*(x-other.x)+(this.y-other.y)*(this.y-other.y)); } }