public static boolean linesIntersect(Line line1, Line line2) {
   if (!(line1.equals(line2))) {
     double x1 = line1.getX1();
     double y1 = line1.getY1();
     double x2 = line1.getX2();
     double y2 = line1.getY2();
     double x3 = line2.getX1();
     double y3 = line2.getY1();
     double x4 = line2.getX2();
     double y4 = line2.getY2();
     return Line2D.linesIntersect(x1, y1, x2, y2, x3, y3, x4, y4);
   } else {
     return false;
   }
 }
 public static String printLine(Line segment) {
   return String.format(
       "(%.1f, %.1f) to (%.1f, %.1f)",
       segment.getX1(), segment.getY1(), segment.getX2(), segment.getY2());
 }