mercredi 26 août 2015

Some Object of a class can have a particular behavior but others doesn't

How can i design this particular Situation.

Basic Diagram of my problem.

Problem is :

  1. if i implement Swim in Bird and add diveNow() behaviour to "fly high" but it is not desired since all birds can't fly.

in other words "Some objects can do that and some can't and both belongs to the same class.

Can i use Strategy Pattern. How? What if i have a huge set of behaviors [Interfaces] having same kind of problem.

Aucun commentaire:

Enregistrer un commentaire