import java.awt.Color; import graphics.*; public class DrawApp { private static int nCircles = 50; // main method public static void main(String[] args) { // Java provides a default constructor (no parameter version) // IF there is NO constructor at all // ERROR: non-default constructor exists in CircularStroke //CircularStroke csDefault = new CircularStroke(); //canvas.resize(400, 400); // create a CircularStroke array of size nCircles CircularStroke[] strokesC = new CircularStroke[nCircles]; SquareStroke[] strokesS = new SquareStroke[nCircles]; //strokes[0].draw(); int cx; int cy; int size = 10; Color c = Color.BLACK; boolean f = true; char choice = canvas.promptChar("Choose stroke type: C or S"); canvas.waitForUserClick(); for (int i = 0; i < nCircles; ++i) { //canvas.clear(); // sample mouse position cx = canvas.getMouseX(); cy = canvas.getMouseY(); if (choice == 'C' || choice == 'c') { //CircularStroke cs = new CircularStroke(cx, cy, r, c, f); CircularStroke cs = new CircularStroke(cx, cy, size, f); cs.draw(); strokesC[i] = cs; } else { SquareStroke ss = new SquareStroke(cx, cy, size, f); ss.draw(); strokesS[i] = ss; } canvas.sleep(0.08); } canvas.waitForUserClick(); canvas.clear(); for (CircularStroke cs : strokesC) { cs.draw(); } for (SquareStroke cs : strokesS) { cs.draw(); } } }