/** * Plots the line segments connecting * (<em>i</em>, <em>a</em><sub><em>i</em></sub>) to * (<em>i</em>+1, <em>a</em><sub><em>i</em>+1</sub>) for * each <em>i</em> to standard draw. * * @param a the array of values */ public static void plotLines(double[] a) { validateNotNull(a); int n = a.length; StdDraw.setXscale(-1, n); StdDraw.setPenRadius(); for (int i = 1; i < n; i++) { StdDraw.line(i-1, a[i-1], i, a[i]); } }
/** * Draws this rectangle to standard draw. */ public void draw() { StdDraw.line(xmin, ymin, xmax, ymin); StdDraw.line(xmax, ymin, xmax, ymax); StdDraw.line(xmax, ymax, xmin, ymax); StdDraw.line(xmin, ymax, xmin, ymin); }