mirror of
https://github.com/processing/processing4.git
synced 2026-02-06 15:19:39 +01:00
29 lines
472 B
Plaintext
29 lines
472 B
Plaintext
// Learning Processing
|
|
// Daniel Shiffman
|
|
// http://www.learningprocessing.com
|
|
|
|
// Example 22-2: Polymorphism
|
|
|
|
class Shape {
|
|
float x;
|
|
float y;
|
|
float r;
|
|
|
|
Shape(float x_, float y_, float r_) {
|
|
x = x_;
|
|
y = y_;
|
|
r = r_;
|
|
}
|
|
|
|
void jiggle() {
|
|
x += random(-1,1);
|
|
y += random(-1,1);
|
|
}
|
|
|
|
// A generic shape does not really know how to be displayed.
|
|
// This will be overridden in the child classes.
|
|
void display() {
|
|
point(x,y);
|
|
}
|
|
}
|