我是初学者,我把我写的给你看看,我们可以一起学习交流的啊~
class Point{
double x,y;
Point(double x,double y){
this.x = x;
this.y = y;
}
double getX(){
return x;
}
double getY(){
return y;
}
}
class Circle{
double r;
Point pp;
Circle(double r){
this.r = r;
pp =new Point (0,0);
}
Circle(double r,Point p ){
this.r = r;
this.pp=p;
}
boolean isContain(Point pt){
double a =(pp.x-pt.x)*(pp.x-pt.x)+(pp.y-pt.y)*(pp.y-pt.y);
double b = this.r*this.r;
if(a return true;
}else{
return false;
}
}
}
public class TestOverLoad{
public static void main (String[] args){
Circle c1=new Circle(1);
Point p=new Point(1,1);
System.out.println(c1.isContain(p));
}
}
太简单,上学那会的作业。
这个构造方法的定义和构造方法的定义就会写了~!
完全没有难度