class Line { int x1, y1, x2, y2; static void print(Line theLine) { System.out.print("(" + theLine.x1 + ", " + theLine.y1 + "):(" + theLine.x2 + ", " + theLine.y2 + ")" ); } static void translate(Line theLine, int dx, int dy) { theLine.x1 = theLine.x1 + dx; theLine.y1 = theLine.y1 + dy; theLine.x2 = theLine.x2 + dx; theLine.y2 = theLine.y2 + dy; } static double length(Line theLine) { int dx = theLine.x1 - theLine.x2; int dy = theLine.y1 - theLine.y2; return Math.sqrt(dx * dx + dy * dy); } } class LineTest { public static void main(String[] args) { Line line1 = new Line(); Line line2 = new Line(); line1.x1 = 10; line1.y1 = 20; line1.x2 = 50; line1.y2 = 100; line2.x1 = 25; line2.y1 = 33; line2.x2 = 99; line2.y2 = 100; System.out.print("Line1: "); Line.print(line1); System.out.println(", length = " + Line.length(line1)); System.out.print("Line2: "); Line.print(line2); System.out.println(", length = " + Line.length(line2)); Line.translate(line1, 100, 200); System.out.print("Line1: "); Line.print(line1); System.out.println(", length = " + Line.length(line1)); } }