/** * This class has a main method in which we use our Line class and * our Point class to create lines */ public class ComputeLines{ public static void main(String[] args){ /** * Let's compute the line through the points (0,0) and (5,0) */ Point p1 = new Point(); // defaults to the origin (0, 0) Point p2 = new Point(5, 0); Line line = new Line(p1, p2); System.out.println("The slope of the line is " + line.getSlope()); System.out.println("The following points are on this line:"); System.out.println("(" + 10.0 + ", " + line.computeY(10.0) + ")"); System.out.println("(" + 20.0 + ", " + line.computeY(20.0) + ")"); System.out.println("(" + 50.0 + ", " + line.computeY(50.0) + ")"); /** * Let's compute the line through the points (1,1) and (2,2) */ double x1 = 1, y1 = 1, x2 = 2, y2 = 2; line = new Line(x1, y1, x2, y2); System.out.println("\n\nThe slope of the line is " + line.getSlope()); System.out.println("The following points are on this line:"); System.out.println("(" + 10.0 + ", " + line.computeY(10.0) + ")"); System.out.println("(" + 20.0 + ", " + line.computeY(20.0) + ")"); System.out.println("(" + 50.0 + ", " + line.computeY(50.0) + ")"); /** * Finally, let's consider the line through the points (2,4) and (5,10) */ line = new Line(2, 4, 5, 10); System.out.println("\n\nThe slope of the line is " + line.getSlope()); System.out.println("The following points are on this line:"); System.out.println("(" + 10.0 + ", " + line.computeY(10.0) + ")"); System.out.println("(" + 20.0 + ", " + line.computeY(20.0) + ")"); System.out.println("(" + 50.0 + ", " + line.computeY(50.0) + ")"); } }