@Test void evaluate() { Line l1 = new Line(-3, 5); assertEquals(l1.evaluate(2), -1); assertEquals(l1.evaluate(-2), 11); Line vertLine = new Line(new Point(0, 5), Double.NEGATIVE_INFINITY); assertThrows(IllegalArgumentException.class, () -> { vertLine.evaluate(0); }); }
public double evaluate(double x) { if (isVerticalLine) { throw new IllegalArgumentException("Cannot evalute values of vertical line"); } else { return x * slope + intercept; } }
Line { public double evaluate(double x) { if (isVerticalLine) { throw new IllegalArgumentException("Cannot evalute values of vertical line"); } else { return x * slope + intercept; } } }
Line { public double evaluate(double x) { if (isVerticalLine) { throw new IllegalArgumentException("Cannot evalute values of vertical line"); } else { return x * slope + intercept; } } Line(Point p1, Point p2);  Line(Point point, double slope);  Line(double slope, double yIntercept); }
Line { public double evaluate(double x) { if (isVerticalLine) { throw new IllegalArgumentException("Cannot evalute values of vertical line"); } else { return x * slope + intercept; } } Line(Point p1, Point p2);  Line(Point point, double slope);  Line(double slope, double yIntercept); double perpendicularSlope(); double evaluate(double x); Point intersect(Line l2); Point nearestLinePoint(Point p); boolean isVertical(); static Point midpoint(Point p1, Point p2); static double distance(Point p1, Point p2); @Override boolean equals(Object o); }
Line { public double evaluate(double x) { if (isVerticalLine) { throw new IllegalArgumentException("Cannot evalute values of vertical line"); } else { return x * slope + intercept; } } Line(Point p1, Point p2);  Line(Point point, double slope);  Line(double slope, double yIntercept); double perpendicularSlope(); double evaluate(double x); Point intersect(Line l2); Point nearestLinePoint(Point p); boolean isVertical(); static Point midpoint(Point p1, Point p2); static double distance(Point p1, Point p2); @Override boolean equals(Object o);  }