Подскажите, как сделать проверку в методе public Point intersection(Line other): если линии не пересекаются или совпадают, метод возвращает null

public class Line {

    private int k;
    private int b;

    public Line(int k, int b) {
        this.k = k;
        this.b = b;

    }

    public Point intersection(Line other) {
        int x = (other.b - this.b) / (this.k - other.k);
        int y = this.k * x + this.b;
        return new Point(x, y);

        }

    }
public class Point {
    private final int x;
    private final int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public String toString() {
        return String.format("(%d;%d)", x, y);
    }
}

Ответы (0 шт):