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).

JAVA: Need help writing Line Class (Problem 2). class PointTest public static

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!