extends.. inheriting
in
Programming Questions
•
2 years ago
I have to learn everything about classes and inheriting..
now I've written a little program on my own (similiar to the example on the processing site), but I don't understand whether this is all you can do with this "extends"?
- Button b1;
- void setup(){
size(200,200);
b1=new Button(10,20,40,50);
} - void draw(){
b1.display();
} - class AllButton{
int x,y,l,b;
void display(){
rect(x,y,b,l);
}
} - class Button extends AllButton{
Button(int xp,int yp, int la, int br){
x=xp;
y=yp;
l=la;
b=br;
} - }
and why is it possible not to have a constructor in the AllButton-class? I thought every class has to have at least one constructor?
thanks for your help..
1