10.4(MyPoint类)设计⼀个名为MyPoint的类
设计⼀个名为Mypoint的类,代表⼀个以x坐标和y坐标表⽰的点。该类包括:
骆驼画法Java源代码:
穿成语class Mypoint{
double x,y;
Mypoint(double x,double y){
this.x =x;
this.y =y;
}
double distance(){
return Math.sqrt((Math.pow(this.x-0,2))+(Math.pow(this.y-0,2)));
浮打一成语>吃阿胶的好处
}
double distance(double x,double y){
重庆武隆旅游攻略
return Math.sqrt((Math.pow(this.x-x,2))+(Math.pow(this.y-y,2)));
}
// double distance(double x1,double y1,double x2,double y2){
// return Math.sqrt((Math.pow(x1-x2,2))+(Math.pow(y1-y2,2)));
// }
static double distance(Mypoint a,Mypoint b){
产品营销策划方案
return Math.sqrt((Math.pow(a.x-b.x,2))+(Math.pow(a.y-b.y,2)));
}
}
public class Mypoint类 {
经典海鲜菜谱
public static void main(String[] args) {
龙山风景区Mypoint a = new Mypoint(0,0);
Mypoint b = new Mypoint(10,30.5);
System.out.println(Mypoint.distance(a,b));
}
}
⼀定要根据题⽬要求,先将函数声明⼀个⼀个列出来,之后再⼀个⼀个进⾏补充实现。这就是套路。