java - Interview follow up on Class Design by avoiding diamond case -


recently have been asked design question. there 2 classes horse , bird. need design new class called unicorn having methods of class horse , bird.

horse          bird      |         |        unicorn 

since in java cant extend 2 classes (to avoid diamond problem) how achieve this?

please guide. in advance.

use façade pattern composition achieve this. unicorn class contain instances of both bird , horse , implement relevant methods calling them on these contained instances.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -