Am sure that , everyone will be aware of the Transformers ( Optimus Prime , Megatron etc).
Am trying to represent that in the form of classes and interface. For now, am not considering the attributes. Am just taking some functionalities.
My Design is
interface Car{
public void run();
public void stop();
}
interface Robot{
public void walk();
public void fight();
}
class Transformer implements Car, Robot {
// implementing all the methods
}
So the class Transformer
says, it can perform both Car and Robot operations
During instantiation
Robot R = new Transformer(); // Now the transformer is in Robot format
Car C = new Transformer(); // Now the transformer is in Car format
My Question is ,here two objects that are getting created Robot R
and Car C
. So, this convey the Robot is getting created and Car is getting created . But what I want is The Car is Getting Transformed to A Robot and Vice Versa
How to implement this in design.