/** * Line - model a line */ public class Line { private double x1; private double y1; private double x2; private double y2; /** * Line - a line in the first quadrant (made up example) * @require both points (x1,y1) and (x2, y2) to be in first quadrant */ public Line(double x1, double y1, double x2, double y2) { this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; assert x1 >= 0 && y1 >= 0 && x2 >= 0 && y2 >= 0 : "A point is not in RHQ"; } public double length() { return Math.sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ); } public static void main( String[] args ) { Line l = new Line(0.,0.,10., -10.); System.out.println( "No assertions" ); } }