A GUI design question
Hi, I'm relatively new in OO programming so I hope this isn't a stupid question.
Suppose we have the following interfaces,
publicinterface Driveable{
publicvoid startDriving();
publicvoid stopDriving();
publicvoid turnLeft();
publicvoid turnRight();
}
publicinterface Flyable{
publicvoid takeOff();
publicvoid land();
publicvoid flightLeft();
publicvoid flightRight();
}
and also the following classes
publicclass Carimplements Driveable{
// interface implementation
}
publicclass Planeimplements Flyable{
// interface implementation
}
publicclass FlyingCarimplements Driveable, Flyable{
// interface implementation
}
The last class could implement Harry Potter's flying car :)
(stolen by the way, http://www.guardian.co.uk/uk_news/story/0,3604,1604151,00.html )
Anyway, each of these classes should have a UI with menus like "Start the car" for the Car class and "Take off the plane" for the Plane class. FlyingCar's UI should have the menus of both Car and Plane UIs and what I ask is, can I take advantage of that fact?
I was thinking of having a common UI class for all three cases and pass the object I want to draw as a parameter. But in this case that class would be filled up with "if" or "switch" statements checking the kind of the object that needs to be drawn, which seems a little ugly to me. Is there any other more convinient way so I don't have to write three times the same code? Or if you think the design could be better, please say so.
Thanks in advance.

