package cn.bunny.pattern2.demo1.duck;

import cn.bunny.pattern2.demo1.behavior.fly.FlyBehavior;
import cn.bunny.pattern2.demo1.behavior.quack.QuackBehavior;
import lombok.Setter;

@Setter
public abstract class AbstractDuck {
    // 设置新的叫声行为
    QuackBehavior quackBehavior;
    // 设置新的飞行行为
    FlyBehavior flyBehavior;

    public AbstractDuck() {
    }

    /**
     * 展示什么类型的鸭子
     */
    public abstract void display();

    public void performFly() {
        flyBehavior.fly();
    }

    public void performQuack() {
        quackBehavior.quack();
    }

    public void swim() {
        System.out.println("鸭子游泳");
    }
}
