oop - multiple inheritance in Java (representing Liger in Java) -


multiple inheritance possible in java using interfaces.so can represent liger object in java? let me give small heads up: liger hybrid cross between male lion , tigress. properties inherited tiger 1. tiger-like striping pattern (attribute- stripes)

properties inherited lion 1. lion-like tawny background (attribute - backgroundcolour) 2. tail more of lion (attribute- tail)

behaviour inherited tiger 1. swimming (method- swim())

behaviour inherited lion 2. sociable similar lions. (method- socialize())

how can represented in java?

i use aggregation, not inheritance. liger combines behaviour of tiger , lion neither 1 nor other. so, aggregation seems better here.

class liger {  private tiger tiger = new tiger(); private lion lion = new lion();  void swim() { tiger.swim(); }  void socialize() { lion.socialize() ; }  tail gettail() { return lion.gettail(); }  skin getskin() { return tiger.getskin(); }  } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -