// An array of Shape objects; remember, we can put any object in here // that inherits from the Shape class. Shape[] shapes = new Shape[25]; void setup() { // setup the environment size(400, 400); colorMode(RGB, 255, 255, 255, 255); smooth(); // Create 25 Shapes, a random selection of circles and square for (int i = 0; i < shapes.length; i++) { int rand = int(random(2)); if (rand ==0) { shapes[i] = new Circle(200, 200, 10, color(32, 64, 128)); } else { shapes[i] = new Square(200, 200, 10); } } } void draw() { // clear the background background(0); // Because both Circle and Square are shape objects, // we can treat all of the objects in the shapes array // the same. The correct shake() and render() methods will // be called for each kind of shape for (int i = 0; i < shapes.length; i++) { Shape myShape = shapes[i]; myShape.shake(); myShape.render(); } }