definition of an equation of a line
Design the class lineType to store line. To store a line, you need to store values of a, b and c. Your class must contain the following operations:
1) If a line is nonvertical, then determine its slope.
2) Determine if two lines are equal.
3) Determine if two lines are parrallel.
4) Determine if two lines are perpendicular.
5) If two lines are not parrallel, then find the point of intersection.
These is my skeleton with comments of my plans. Need help making a constructor!
import java.util.*; public class Linetype { static Scanner ci = new Scanner(System.in); public class Line{ private double a, b, c; // how to make a contructor here? } public void slope(){ double a=0, b=0, c; if ( a == 0 && b != 0) System.out.println("The slope of the line is horizontal"); else if (b == 0) System.out.println("The slope of the line is vertical " + "and undefined"); else c = (-1*a)/b;} public boolean equal(){ int a1=0, a2=0, b1=0, b2=0, c1, c2; boolean result; c1 = a1 + b1; c2 = a2 + b2; // replace all these variable with line1==line2 if (a1 == a2 && b1 == b2 && c1 == c2){ result = true;} else result = false; return result; } public class Parallel{ // compare slope if equal then parallel or both vertical // if not parralel find the point of intersection // y=(c-a*x)/b and x=(c-b*y)/a ? } public class Perpendicular{ //slope of line1 times line2 is negative one // or line1 is horizontal and line2 is vertical } public static void main(String[] args) { Line line1 = new Line(); Line line2 = new Line(); // prompt the user to enter the values of a,b and c. Taking suggestions! } }