mirror of
https://github.com/processing/processing4.git
synced 2026-02-08 08:09:32 +01:00
26 lines
609 B
Plaintext
26 lines
609 B
Plaintext
// Learning Processing
|
|
// Daniel Shiffman
|
|
// http://www.learningprocessing.com
|
|
|
|
// Example 22-2: Polymorphism
|
|
|
|
class Square extends Shape {
|
|
// Variables are inherited from the parent.
|
|
// We could also add variables unique to the Square class if we so desire
|
|
|
|
Square(float x_, float y_, float r_) {
|
|
// If the parent constructor takes arguments then super() needs to pass in those arguments.
|
|
super(x_,y_,r_);
|
|
}
|
|
|
|
// Inherits jiggle() from parent
|
|
|
|
// The square overrides its parent for display.
|
|
void display() {
|
|
rectMode(CENTER);
|
|
fill(175);
|
|
stroke(0);
|
|
rect(x,y,r,r);
|
|
}
|
|
}
|