Ho creato due chicchialternativa di ereditarietà multipla in Java
class BackPageBean{
String backPage = null;
:
:
:
}
class InformationMessageBean{
String informationMessage = null;
:
:
:
}
Ora, se una classe è backpage a conoscenza allora si estenderà backPageBean, o se ha bisogno di mostrare un qualche tipo di messaggio, allora si estende InformationMessageBean.
class BackPageAware extends backPageBean{
}
class InfoMessAware extends InformationMessageBean{
}
someFunction() {
if (theObject instanceOf backPageBean) {
prepareTheBackPage (theObject.getBackPage());
}
if (theObject instanceOf InformationMessageBean) {
showtheInformation (theObject.getMessage());
}
}
Ora il problema è, se voglio avere un fagiolo che è sia BackPageAware così come InformationAware allora, come non abbiamo l'ereditarietà multipla, quello che dovrebbe essere l'approccio?
È Java. Non JAVA. –
non l'ho mai saputo, thnx: D –