Question: JAVA: Need help writing Line Class (Problem 2). class PointTest public static void main (String[] args) Point point - new Point (10,20) System . out.println(A:
JAVA: Need help writing Line Class (Problem 2).

class PointTest public static void main (String[] args) Point point - new Point (10,20) System . out.println("A: " + point.toString()); foo (point) System.out.println("B: " +point.toString O) static void foo (Point point) system . out.printin (": " + point . tostring()); point = new Point (5,6); // caution : a trick? System.out.printin("D:"point.tostring)) class Point private int x, y Point (int x, int y) { this.x = x; this . y = y;} public String toStringO return"("+x + ", "+ y+ ")" 2. (4 points) Write a complete Line class using the Point class from the previous problem. A Line is described by two points representing the two ends of the line. Your Line class should work with the following test program generating the output shown. class LineTest public static void main (String] args) Point pl-new Point (10,20) Point p2-new Point (50, 60) Line line1 = new Line (p1,p2); System.out.printin (line1.tostring O) The output of the above program should be: (10,20): (50,60)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
