Question: import java.util.*; public class Lab8 { public static void main(String[] args) { Point[] points = new Point[4]; points[0] = new Point(1,1); //fill the rest of
![import java.util.*; public class Lab8 { public static void main(String[] args)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f524a44d583_73166f524a3c0196.jpg)
import java.util.*;
public class Lab8 { public static void main(String[] args) { Point[] points = new Point[4];
points[0] = new Point(1,1); //fill the rest of the array with the points (3,3), (0,4), and (1,6)
//create a Line object with the first two points in the array. Call it line1 //create a Line object with the second two points in the array. Call it line2.
//print line1 by calling toString
//print line2 by calling toString
//call 'intersects' method to see if line1 intersects line2. //Store the result in a boolean variable.
//if the result is true, print "Lines intersect"
//if the result is not true, print "Lines do NOT intersect" } // end main } // end class
public class Line { private double slope; private double y_intercept;
public Line(Point first, Point second) { //initialize slope and y_intercept (use forumula from the lab writeup) //can access point values like this: first.getX() } // end 2-arg constructor
public String toString() { //return a string of the form "y=mx+b" representing this line //DO NOT print it here //m is the slope and b is the y_intercept
} // end toString()
public boolean intersects(Line another) { //return true if THIS line (using the slope and y_intercept instance variables) //intersects another
//two lines will intersect if their slopes are different //they will also intersect if the slopes AND y_intercepts are the same //otherwise, they will not intersect } // end intersects()
} // end class
//Completed file given as a starter file
public class Point { private int x; private int y;
public Point(int newX, int newY) { x = newX; y = newY; } // end 2-arg constructor
public int getX() { return x; } // end getX()
public int getY() { return y; } // end getY() } // end class
please write me the code thank you
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
