我想测试Point对象列表中是否有正方形.
这是我的Point类:
class Point {
private int x;
private int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int distanceSquare(Point q) {
return (x - q.getX()) * (x - q.getX()) +
(y - q.getY()) * (y - q.getY());
}
}
Run Code Online (Sandbox Code Playgroud)
我可以测试四个Point是否为Square: …