📄 point.java
字号:
import java.math.*;
public class Point {
/**
* @param args
*/
int num=0;
private double x;
private double y;
Point(){
num ++;
System.out.println("This is the "+num+" object");
}
void setPoint(double a,double b){
this.x=a;
this.y=b;
}
void getPoint(){
System.out.println("(x,y)="+"("+this.x+","+this.y+")");
}
double distence(Point point2){
return Math.sqrt((this.x-point2.x)*(this.x-point2.x)+(this.y-point2.y)*(this.y-point2.y));
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Point pt1=new Point();
//pt1.pointmsg();
pt1.setPoint(2.0, 1.0);
pt1.getPoint();
Point pt2=new Point();
//pt2.pointmsg();
pt2.setPoint(8.0, 9.0);
pt2.getPoint();
double dis=0.0;
dis=pt1.distence(pt2);
System.out.println("The distence between Point1 and Point2 is "+dis);
Point pt3=new Point();
pt3.setPoint(7, 13);
System.out.println("The distence between Point1 and Point3 is "+pt1.distence(pt3));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -