小编Moh*_*med的帖子

检测点列表中的方块

我想测试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: …

java algorithm point

5
推荐指数
2
解决办法
902
查看次数

标签 统计

algorithm ×1

java ×1

point ×1