Esempio n. 1
0
        /// <summary>
        /// Creates the eat behavior.
        /// </summary>
        /// <param name="type">The type of eat behavior the animal should perform.</param>
        /// <returns>Return the type of eat behavior.</returns>
        public static IEatBehavior CreateEatBehavior(EatBehaviorType type)
        {
            IEatBehavior eatBehavior = null;

            switch (type)
            {
            case EatBehaviorType.Consume:
                eatBehavior = new ConsumeBehavior();
                break;

            case EatBehaviorType.BuryAndEatBone:
                eatBehavior = new BuryAndEatBoneBehavior();
                break;

            case EatBehaviorType.ShowAffection:
                eatBehavior = new ShowAffectionBehavior();
                break;
            }

            return(eatBehavior);
        }
Esempio n. 2
0
 public People(IEatBehavior behavior)
 {
     this.behavior = behavior;
 }
Esempio n. 3
0
 public Dog(IEatBehavior behavior)
 {
     this.behavior = behavior;
 }
Esempio n. 4
0
 public void SetEatingBehavior(IEatBehavior eb)
 {
     EatBehavior = eb;
 }