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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -