/* Class that represents a line in 2-D cartesian space using the formula a*x + b*y + c = 0 * The class will store a, b, c and allow you to adjust these and test to see if a given point is on the line or not. * The toString returns a*x + b*y + c = 0 where a, b, c are filled in. The class has typical accessors and mutators. */ public class Line { private int a, b, c; // the three coefficients for our equation of a line (ax + by + c = 0) public Line() // initial line, we do not know any of the coefficients { a = b = c = 0; } public Line(int newA, int newB, int newC) // initial line, we know all 3 coefficients { a = newA; b = newB; c = newC; } public int getA() { return a; } // accessors public int getB() { return b; } public int getC() { return c; } public void setA(int newA) { a = newA; } // mutators public void setB(int newB) { b = newB; } public void setC(int newC) { c = newC; } public boolean onLine(int x, int y) // a point is on our line if ax + by + c = 0 { if(a*x+b*y+c==0) return true; else return false; } public String toString() // return the equation for our line { return "" + a + " * x + " + b + " * y + " + c + " = 0"; } }