JAVA中如何用函数来对地理坐标点的匹配?
答案:1 悬赏:20
解决时间 2021-01-30 15:52
- 提问者网友:我稀罕你
- 2021-01-29 19:05
JAVA中如何用函数来对地理坐标点的匹配?
最佳答案
- 二级知识专家网友:承载所有颓废
- 2021-01-29 20:12
class LocPoint
{
private double x,y;
public LocPoint(double x,double y)
{
if(x>=0&&y>=0)
{
this.x=x;
this.y=y;
}
else
{
System.out.println("输入的坐标有误");
}
}
public boolean getlocation()
{
if((double)(Math.sqrt((this.x-112.32)*(this.x-112.32)+(this.y-54.3)*(this.y-54.3)))<0.01)
return true;
else
return false;
}
}
public class Test1
{
public static void main(String[] args)
{
LocPoint[] a=new LocPoint[2];
a[0]=new LocPoint(112.32,54.3);
a[1]=new LocPoint(450,200);
for(int i=0;i<a.length;i++)
{
boolean b=a[i].getlocation();
if(b)
System.out.println("是同一点");
else
System.out.println("不是同一点");
}
}
}
{
private double x,y;
public LocPoint(double x,double y)
{
if(x>=0&&y>=0)
{
this.x=x;
this.y=y;
}
else
{
System.out.println("输入的坐标有误");
}
}
public boolean getlocation()
{
if((double)(Math.sqrt((this.x-112.32)*(this.x-112.32)+(this.y-54.3)*(this.y-54.3)))<0.01)
return true;
else
return false;
}
}
public class Test1
{
public static void main(String[] args)
{
LocPoint[] a=new LocPoint[2];
a[0]=new LocPoint(112.32,54.3);
a[1]=new LocPoint(450,200);
for(int i=0;i<a.length;i++)
{
boolean b=a[i].getlocation();
if(b)
System.out.println("是同一点");
else
System.out.println("不是同一点");
}
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯