コード例 #1
0
        public static void testar()
        {
            Duck pato = new Duck();

            pato.display();

            Duck patomau = new MallarDuck();

            patomau.display();

            ReadHeadDuck patovermelho = new ReadHeadDuck();

            patovermelho.fly();

            Duck patoborracha = new RubberDuck();

            patoborracha.display();

            Duck patoMadeira = new DuckWood();

            patoMadeira.display();
            patoMadeira.quack();


            Duck patoMetal = new DuckMetal();

            patoMetal.display();
            patoMetal.quack();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: oleg987/Interfaces
        static void Main(string[] args)
        {
            Duck duck = new MallardDuck(new FlyByWings(), new Quack());

            duck.Fly();
            duck.Swim();
            duck.Quack();

            Console.WriteLine();

            Duck duck1 = new RubberDuck(new FlyNoWay(), new Squick());

            duck1.Fly();
            duck1.Swim();
            duck1.Quack();

            Console.WriteLine();

            Duck duck2 = new DecorDuck(new FlyNoWay(), new MuteQuack());

            duck2.ChangeFlyBehavior(new RocketFly());
            duck2.Fly();
            duck2.Swim();
            duck2.Quack();

            Console.WriteLine();

            FlyByWings fly = new FlyByWings();

            IFlyBehavior fly1 = (IFlyBehavior)fly;

            SwimAndFly swimAndFly = new SwimAndFly();

            swimAndFly.Swim();
            swimAndFly.Fly();

            IFlyBehavior fly2 = (IFlyBehavior)swimAndFly;

            ISwimBehavior swim = (ISwimBehavior)swimAndFly;

            Phone phone = new Phone();

            ((IEmailSender)phone).Send();
            ((ISmsSender)phone).Send();
        }
コード例 #3
0
        public static void testar()
        {
            Duck pato = new Duck();

            pato.display();

            Duck patomau = new MallarDuck();

            patomau.display();

            ReadHeadDuck patovermelho = new ReadHeadDuck();

            patovermelho.fly();

            Duck patoborracha = new RubberDuck();

            patoborracha.display();
        }