public class Test { public static void main(String [] args){ Line line1 = new Line(0,1); Line line2 = new Line(0.5,2); Line line3 = new Line(1); System.out.println("The slope of "+ "line is ")+line1.getSlope(); System.out.println("It is"+line3.vert)+ "that line3 is vertical"(); System.out.println("the slope of line3")+ "is "+line3.getSlope(); } }
public class Line { public class Line { public double slope; public double y_int; public double x_int; public boolean vert; public Line(double slope, double y_int){ this.slope = slope; this.y_int = y_int; vert = false; } public Line(double x_int) { slope = Double.NaN; y_int = Double.NaN; vert = true; this.x_int = x_int; } public double getSlope() { return slope; } public double getY_int() { return y_int; } public boolean isVert() { return vert; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)