I’ve a created a class called “Animal” as shown below:
class Animal{
int eyes,legs;
}
I’ve four more class which will inherit Animal class as shown below:
class Monkey extends Animal
{
int hands;
Monkey(){
super.eyes=2;
super.legs=2;
hands=2;
}
}
class squirell extends Animal{
int hands;
int hands;
Squirrel(){
super.eyes=2;
super.legs=2;
hands=2;
}
}
class piegon extends Animal{
int wings;
piegon(){
super.eyes=2;
super.legs=2;
wings=2;
}
}
class eagle extends Animal{
int wings;
eagle(){
super.eyes=2;
super.legs=2;
wings=2;
}
}
And I’ve Ladder class which uses “contains” relationship.. Ladder “contains” Monkey,Eagle,Piegon etc..
Here I want to create ladder object and I want to “place” various animals on ladder.
I wanted to create various animal objects using constructor of Ladder class. How can I do that?? Can anyone help me.?
I’m not quite sure what your complete goal is, but in order to “Place” these objects onto your ladder, you might want something like: