using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DuckModel
{
    public interface IFlyBehaviour
    {
        void Fly();
    }
    
    public interface IQuackBehaviour
    {
        void Quack();
    }
    public abstract class DuckBehaviour
    {
        IFlyBehaviour _flyBehaviour;
        IQuackBehaviour _quackBehaviour;

        public void Swim()
        {
            Console.WriteLine("The duck swims");
        }

        public abstract void Display();

        void PerformQuack()
        {
            _quackBehaviour.Quack();
        }

        void PerformFly()
        {
            _flyBehaviour.Fly();
        }

        protected void SetFlyBehaviour(IFlyBehaviour flyBehaviour)
        {
            _flyBehaviour = flyBehaviour;
        }

        protected void SetQuackBehaviour(IQuackBehaviour newBehaviour)
        {
            _quackBehaviour = newBehaviour;
        }
    }

    class Quack : IQuackBehaviour
    {
        void IQuackBehaviour.Quack()
        {
            Console.WriteLine("The duck quacks");
        }
    }

    class Squeak : IQuackBehaviour
    {
        void IQuackBehaviour.Quack()
        {
            Console.WriteLine("The duck squeaks");
        }
    }

    class MuteQuack : IQuackBehaviour
    {
        void IQuackBehaviour.Quack()
        {
            Console.WriteLine("The duck makes no sound");
        }
    }

    class FlyWithWings : IFlyBehaviour
    {
        public void Fly()
        {
            Console.WriteLine("The duck flies away");
        }
    }

    class NoFly : IFlyBehaviour
    {
        public void Fly()
        {
            Console.WriteLine("The duck cannot fly");
        }
    }
}
