コード例 #1
0
        static void Main(string[] args)
        {
            Duck rubber = new RubberDuck();

            rubber.Display();
            rubber.PerformFly();
            rubber.FlyBehavior = FlyRocketPowered.Fly;
            rubber.PerformFly();
            rubber.PerformQuack();
            rubber.QuackBehavior = MuteQuackR.Quack;
            rubber.PerformQuack();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Duck rubber = new RubberDuck();

            rubber.Display();
            rubber.PerformFly();
            rubber.SetFlyBehavior(new FlyRocketPowered());
            rubber.PerformFly();
            rubber.PerformQuack();
            rubber.SetQuackBehavior(new SqueakR());
            rubber.PerformQuack();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Ksyuint/design-patterns
        public static void Main(string[] args)
        {
            MallardDuck mallard      = new MallardDuck();
            RubberDuck  rubberDuckie = new RubberDuck();
            DecoyDuck   decoy        = new DecoyDuck();

            ModelDuck model = new ModelDuck();

            mallard.PerformQuack();
            rubberDuckie.PerformQuack();
            decoy.PerformQuack();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }