Question: package test; public class Point { // data fields private double x, y; //Constructor1 public Point(){ x = 0; y = 0; } // Constructor2

Problem 2. Point and Line Class Please first download the attached Point.java file which contains the definition for the point class. Read the codes and understand what the data fields and methods the point class has. Given the UML, diagram in the following Fig2, define and implement the Line class, two of whose data fields are two Point objects. Write the client program named Line Test.java to test the methods of the Line class Line -start: Point -end: Point -slope: double -intercept: double +Line) +Line(pl: Point, p2: Point) +move(double double y) *getLength(): double +isParallelother: Line):bool +getslope(): double +getintercept(): double intersectionPoint(other: Line):Point 1) move() function will move both the start Point and end point by x and y accordingly. 2) getLength() computs and returns the length of this line. It is known that the length of a line can be computed as length = (start.x-end. x)+ start.y-end.') 3) The slope of a line can be determined by: slope = (end.y-starty)/(end.x-start.x) 4) The intercept of a line can be determined by: intercepta starty - slopestart.x 5) Two lines will be parallel is they have the same slope but different intercept. 6) If two lines (linel and line2) are not parallel, they will be intersected. The intersection point (p) can be determined by: p.x = (line2.intercept-line.intercept)/(line slope-line2 slop) py = line 1.slope *px + line intercept Outputs: For Line 1: Please enter the x and y coordinates for Point 1:11 Please enter the x and y coordinates for Point 2:48 The length of this line is: 7.6158 The slope of this line is: 2.3333 The intercept of this line is: -1.3333 For Line 2: Please enter the x and y coordinates for Point 1:25 Please enter the x and y coordinates for Point 2:32 The length of this line is: 3.1623 The slope of this line is: -3 The intercept of this line is: 11 Line 1 and Line 2 is not parallel They will intersect at Point: (2.3125, 4.0625)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
