// The Circle class is a subclass of the Widget class // It inherits all attributes of Widget and adds a color attribute class Circle extends Widget { // Attributes // inherit x, y, s from Widget color c; // circle color
// Constructor(s) Circle(float x, float y, float s, color c) { super(x, y, s); // Calling the superclass's (Widget's) constructor this.c = c; } // Circle()
// Methods
// inherits jiggle() and toString() from Widget
// Defines the display() abstract method void display() { push(); ellipseMode(CENTER); fill(c); noStroke(); ellipse(x, y, s, s); pop(); } // display()
// Adds a new method just for this class void changeColor() { c = color(random(255), random(255), random(255)); } // changeColor()
void jiggle() { s = s + random(-1, 1); } // jiggle() } // class Circle