Can you answer the given questions?
Question 1: Write a Point class. A Point should have the subsequent:
- two private double fields, x and y, representing the coordinates of the Point
- a constructor that takes two double parameters with which to initialize a Point's fields
- get and set methods for the x and y coordinates
Question 2: Write a Line class. A Line should have the subsequent:
- two private Point fields, p1 and p2, representing two points of the LineSegment
- a constructor that takes two Point parameters with which to initialize a Line's fields
- get and set methods for the two points
- an intersects method that takes a Line parameter and will return a new Point object representing where the two Lines intersect.
If the two Lines are parallel, you should return null. The header will look like this: "public Point intersects (Line otherLine)".
Question 3: Write a void method that takes as a parameter an array of Lines and prints out the location of each intersection. The intersection of any two lines should only be printed once (in other words, don't print the intersection of line1 and line2, and then print the intersection of line2 and line1).
Solve these questions in details and give examples to support your rationale. Be sure to add comments. Comments should be added in the program to explain your calculations and program.