/**
 *  Tests out the Point and Line classes.
 */
public class GeometryTest {
    private static void testSatisfies(Line line, Point point) {
        System.out.print("Point " + point);
        if (line.satisfies(point)) {
            System.out.print(" is on line ");
        } else {
            System.out.print(" is NOT on line ");
        }
        System.out.println(line);
    }
    public static void main(String[] args) {
        Point pt = new Point(3, 4);
        System.out.println("pt = " + pt);
        Point pt2 = new Point(15, 10);
        System.out.println("Distance: " + pt.distance(pt2));
        Line line = new Line(pt, pt2);
        System.out.println("Line: " + line);
        System.out.println("Slope: " + line.slope());
        //  On the line
        testSatisfies(line, new Point(5, 5));
        //  Not on the line
        testSatisfies(line, new Point(5, 6));
        Line line2 = new Line(new Point(3, 10), new Point(15, 3));
        System.out.println(
            line + " intersects " + line2 + " at " + line.intersect(line2));
        //  Sanity check--point of intersection should satisfy both lines
        pt2 = line.intersect(line2);
        testSatisfies(line, pt2);
        testSatisfies(line2, pt2);
        //  Test vertical line
        line = new Line(new Point(10, 10), new Point(10, 20));
        System.out.println("Vertical line: " + line);
        //  Test horizontal line
        line = new Line(new Point(10, 10), new Point(20, 10));
        System.out.println("Horizontal line: " + line);
        //  Where do these horizonal and vertical lines intersect?
        System.out.println(
            new Line(new Point(10, 5), new Point(10, 20)).intersect(
                new Line(new Point(5, 10), new Point(20, 10))));
        //  Test the Point get and set methods
        Point p = new Point(0, 0);
        System.out.println("p = " + p);
        p = new Point(10, -3.5);
        System.out.println("p = " + p);
        Point pCopy = new Point(p);
        System.out.println("pCopy = " + pCopy);
    }
}
