Here is a small artificial example of what I am trying to achieve. I have a class with many parameters - Dog
. I have a child class JumpyDog
and I want to learn how can I can "extend" the instance of Dog
to make it an instance of JumpyDog
.
class Dog {
int age, numberOfTeeth, grumpiness, manyOtherParameters;
JumpyDog learnToJump(int height) {
JumpyDog jumpy = new JumpyDog(this); // I do not want to copy all parameters
jumpy.jumpHeight=height;
return jumpy;
}
}
class JumpyDog extends Dog {
int jumpHeight;
void jump(){}
}
Or can I say something like that:
Dog dog=new Dog();
dog.makeJumpy();
dog.jump()