java обработка собственных исключений

Я хочу выдать исключение, то есть сообщение об ошибке создания треугольника, если пользователь введет координаты точек, которые будут лежать на одной прямой. Но программа не сообщает об ошибке пользователю и все равно создает такой треугольник. Пожалуйста, скажите мне, где я допустил ошибку, что я делаю не так?

public class EightLab {
    public static void getInconsistency(double [] x_points,double [] y_points)throws InconsistencyException{

        if ((x_points[2] - x_points[0]) / (x_points[1] - x_points[0]) == (y_points[2] - y_points[0]) / (y_points[1] - y_points[0])) {
            throw new InconsistencyException("the points lie on the same line, a triangle cannot be created");
        }
    }

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        
        double[] x_points = new double[3];
        double[] y_points = new double[3];

        System.out.println("Enter the coordinates of the points ");
        for (int i =0 ; i<3; i++) {
            x_points [i] = scanner.nextDouble();
            y_points [i] = scanner.nextDouble();
        }
        try {
            EightLab.getInconsistency(x_points, y_points); 
            Point a_new = new Point (x_points [0],y_points [0]);
            Point b_new = new Point (x_points [1],y_points [1]);
            Point c_new = new Point (x_points [2],y_points [2]);
            Triangle T_new = new Triangle(a_new, b_new, c_new);
            System.out.println("Triangle = \n" + T_new.Draw());
        }
        catch(InconsistencyException ex){
            System.err.println(ex.getMessage());
        }

    }

Кстати.Пробовал и такой метод сравнения значений с плавающей точкой, но и это не помогло

double temp1=(x_points[2] - x_points[0]) / (x_points[1] - x_points[0]);
double temp2=(y_points[2] - y_points[0]) / (y_points[1] - y_points[0]);
if (Math.abs(temp1 - temp2) < 0.00001) {
    throw new InconsistencyException("the points lie on the same line, a triangle cannot be created");
}

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