JAVA定义类证明两圆是同心圆的程序全码。。

来源:百度知道 编辑:UC知道 时间:2024/06/23 14:57:05
用类的问题证明两圆是同心圆

class round
{int[] point;
int size;
public round(int x,int y,int size)
{
this.point[0]=x;
this.point[1]=y;
this.size=size;}
public int checked(round temp)
{if(temp.point[0]==this.point[0]&&temp.point[1]==this.point[1])
if(temp.size==this.size)return 2;
else return 1;
else return 0;

}
}
public class a
{
public static void main(String args[])
{
round x1=new round(1,2,3);
round x2=new round(1,2,5);

if(x1.checked(x2)==1)
System.out.println("是同心圆");
else if(x1.checked(x2)==2)
System.out.println("两圆是相同的");
else if(x1.checked(x2)==0)
System.out.println("两圆没有任何关系");

}

}

class Circle {
public int x;//圆心的x坐标
public int y;//圆心的y坐标
public int r;//圆的半径
public Circle(int x, int y, int r) {
this.x = x;
this.y = y;
this.r = r;<