用JAVA编写一个点在不在圆内,里面该怎么填?public class Circle{Point center;int radius;public Circle(Point center,int radius){///.}//.getter/setter .// .printInfo .// 该圆的圆心是:(3,4),半径是:5//求某一个点是否在本圆
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 21:35:00
用JAVA编写一个点在不在圆内,里面该怎么填?public class Circle{Point center;int radius;public Circle(Point center,int radius){///.}//.getter/setter .// .printInfo .// 该圆的圆心是:(3,4),半径是:5//求某一个点是否在本圆
用JAVA编写一个点在不在圆内,里面该怎么填?
public class Circle{
Point center;
int radius;
public Circle(Point center,int radius){
///.
}
//.getter/setter .
// .printInfo .
// 该圆的圆心是:(3,4),半径是:5
//求某一个点是否在本圆内
public boolean isInside(Point p){
///.
}
//求两个圆心之间的距离的平方
public int distance(Circle c){
///.
}
public static void main(String[] args){
Point p1 = new Point(1,1);
Circle c1 = new Circle(p1,3);
c1.printInfo();
Point p2 = new Point(5,5);
boolean f = c1.isInside(p2); //false
System.out.println(f);
Point p3 = new Point(7,8);
Circle c2 = new Circle(p3,5);
int dis = c1.distance(c2);
System.out.println("两个圆之间的距离的平方是:" + dis);
}
}
用JAVA编写一个点在不在圆内,里面该怎么填?public class Circle{Point center;int radius;public Circle(Point center,int radius){///.}//.getter/setter .// .printInfo .// 该圆的圆心是:(3,4),半径是:5//求某一个点是否在本圆
哥们,首先告诉你这是一道数学题不是编程题,你这少个Point的类,我们暂且用p.x\p.y来描述p点的xy坐标,有不懂可以再问我.
//求某一个点是否在本圆内
public boolean isInside(Point p){
Boolean bool=false
if(((p.x-3)*(p.x-3)+(p.y-4)*(p.y-4))==5*5) {
bool=true;
}
return bool;
}
//求两个圆心之间的距离的平方
public int distance(Circle c){
int s=0;
s= ((p.x-3)*(p.x-3)+(p.y-4)*(p.y-4));
return s;
}