欧几里德平面中的点
下面的程序定义了Point类,我的问题标在代码中
public class Point{
protected double x,y;
public Point(double x,double y)
{ this.x=x;
this.y=y;
}
public double getX()
{return x;
}
public double getY()
{return y;
}
public Point getLocal()
{ return new Point(x,y);
}
public void setLocal(double x,double y)
{ this.x= x;
this.y= y;
}
public void translate(double dx,double dy)
{ x+= dx;
y+= dy;
}
public boolean equals(Object ob)
{ if(ob==this) return true;
if(ob.getClass()!=this.getClass()) return false;
Point point=(Point)ob;
return(x==point.x&&y==point.y);
}//问题1
public int hashCode()
{ return(new Double(x).hashCode()+(new Double(x)).hashCode());
}//问题2
public String toString()
{ return new String("("+(float)x+" ,"+(float)y+")");
}
}
以上都编译通过,并且能用主类调用。
问题1:getClass是什么方法?有什么用。哪些类型能用它?
问题2:hashCode是什么方法?有什么用。哪些类型能用它?
不知我说的可详细,请赐教》》》》
public class Point{
protected double x,y;
public Point(double x,double y)
{ this.x=x;
this.y=y;
}
public double getX()
{return x;
}
public double getY()
{return y;
}
public Point getLocal()
{ return new Point(x,y);
}
public void setLocal(double x,double y)
{ this.x= x;
this.y= y;
}
public void translate(double dx,double dy)
{ x+= dx;
y+= dy;
}
public boolean equals(Object ob)
{ if(ob==this) return true;
if(ob.getClass()!=this.getClass()) return false;
Point point=(Point)ob;
return(x==point.x&&y==point.y);
}//问题1
public int hashCode()
{ return(new Double(x).hashCode()+(new Double(x)).hashCode());
}//问题2
public String toString()
{ return new String("("+(float)x+" ,"+(float)y+")");
}
}
以上都编译通过,并且能用主类调用。
问题1:getClass是什么方法?有什么用。哪些类型能用它?
问题2:hashCode是什么方法?有什么用。哪些类型能用它?
不知我说的可详细,请赐教》》》》
...全文
相关推荐
基于欧几里德聚类的障碍物检测ROS实现.zip
**欧几里德聚类**: 欧几里得聚类是一种无监督学习方法,主要用于三维空间中的点云数据处理。
基于欧几里德聚类的障碍物检测ROS实现
ROS提供了多种地面平面检测方法,如`pcl::SACSegmentation`可以用来估计地面平面,然后使用`pcl::ExtractIndices`去除地面点,只保留可能代表障碍物的非地面点。
安全技术-网络信息-欧几里德2连通Steiner网络问题研究.pdf
本篇论文针对的中心议题是欧几里德2连通Steiner网络问题的研究。该问题属于组合优化领域中的一个经典问题,其目的是在给定的一组平面点集中,找到长度最小的2连通Steiner网络。
IQ调制与星座图原理[项目源码]
为了进一步理解星座图在通信系统中的重要性,文章分析了星座图的各种特性,例如最小欧几里德距离和最小相位偏移。最小欧几里德距离决定了系统抗干扰的能力,而最小相位偏移则与调制信号的相位噪声相关。
Closest-Pairs
在描述中提到,程序需要接收任意数量的整数,并找出其中最短的欧几里德距离对。这意味着我们需要一个有效的算法来处理这个问题,考虑到输入的限制是整数和非负整数,我们可以假设这些点都在正方形或矩形区域内。


