示例#1
1
 static void Main(string[] args)
 {
     Duck mallard = new MallardDuck();
     mallard.PerformQuack();
     mallard.PerformFly();
     Console.ReadLine();
 }
        static void Main(string[] args)
        {
            // Pato Bravo
            MallardDuck md = new MallardDuck();
            md.Display();
            md.Swim();
            md.Fly();
            md.Quack();
            System.Console.WriteLine("\n");

            // Pato Cabeça-vermelha
            RedHeadDuck rhd = new RedHeadDuck();
            rhd.Display();
            rhd.Swim();
            rhd.Fly();
            rhd.Quack();
            System.Console.WriteLine("\n");

            // Pato de Borracha
            RubberDuck rd = new RubberDuck();
            rhd.Display();
            rhd.Swim();
            rd.Quack(); // Chia invés de grasnar
            System.Console.WriteLine("\n");

            Console.ReadKey();
        }
示例#3
0
        // Code using the template method pattern
        void flyTheDucks_Click(object sender, EventArgs e)
        {
            Duck mallard = new MallardDuck();
            mallard.Migrate();

            Duck mandarin = new MandarinDuck();
            mandarin.Migrate();
        }
        public void TestMallardDuck()

        {
            Duck mallard = new MallardDuck();

            Assert.AreEqual("Quack", mallard.Quack());

            Assert.AreEqual("I'm flying", mallard.Fly());
        }
        public void DuckShouldQuack()
        {
            var expected = "Quack";

            MallardDuck mallardDuck = new MallardDuck();

            var result = mallardDuck.Quack();

            result.Should().Be(expected);
        }
示例#6
0
        static void Main(string[] args)
        {
            // Duck
            var mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();

            Console.ReadLine();
        }
示例#7
0
        private static void Main()
        {
            var mallard = new MallardDuck {
                Quacker = new QuackNormal()
            };

            mallard.Display();
            mallard.Flyer = new FlyWings();
            mallard.Display();
        }
示例#8
0
        public static void Main(string[] args)
        {
            Duck mallardDuck = new MallardDuck();

            mallardDuck.PerformFly();
            mallardDuck.PerformQuack();

            mallardDuck.SetFlyBehaviour(new RocketFly());
            mallardDuck.PerformFly();
        }
        public void DuckShouldFly()
        {
            var expected = "Weeeee";

            MallardDuck mallardDuck = new MallardDuck();

            var result = mallardDuck.Fly();

            result.Should().Be(expected);
        }
示例#10
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Duck mallard = new MallardDuck();

            mallard.PerformFly();
            mallard.PerformQuack();

            mallard.SetFlyBehaviour(new FlyNoWay());
            mallard.PerformFly();
        }
示例#11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start!");
            Duck mallard = new MallardDuck();

            mallard.performQuack();
            Console.WriteLine("Done!");

            Console.WriteLine("Press enter to quit...");
            Console.ReadLine();
        }
示例#12
0
        public void TestMallardDuckQuack()
        {
            Duck   duck = new MallardDuck();
            string text = "Quack, quack!\r\n";

            using (var consoleOutput = new ConsoleOutput())
            {
                duck.Quack();
                Assert.AreEqual(text, consoleOutput.GetOutput());
            }
            Assert.AreEqual(currentConsoleOut, Console.Out);
        }
示例#13
0
    private void Start()
    {
        MallardDuck duck          = new MallardDuck();
        WildTurkey  turkey        = new WildTurkey();
        Duck        turkeyAdapter = new TurkeyAdapter(turkey);

        Debug.Log("오리 사용...");
        testDuck(duck);

        Debug.Log("칠면조로 대체...");
        testDuck(turkeyAdapter);
    }
        public void MallardDuck()
        {
            // Arrange
            var appConsoleOutput = SetupConsoleOutput();
            var mallardDuck = new MallardDuck();

            // Act
            TestDuck(mallardDuck);

            // Assert
            ApprovalTests.Approvals.Verify(appConsoleOutput);
        }
        public void DuckAdapterTest()
        {
            MallardDuck duck        = new MallardDuck();
            ITurkey     duckAdapter = new DuckAdapter(duck);

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("The DuckAdapter says...");
                duckAdapter.Gobble();
                duckAdapter.Fly();
            }
        }
示例#16
0
        public static void Test_1()
        {
            var mallardDuck = new MallardDuck();

            mallardDuck.Display();
            mallardDuck.PerformFly();
            mallardDuck.SetFlyBehavior(new FlyNoWay());
            mallardDuck.PerformFly();
            mallardDuck.PerformQuack();
            mallardDuck.SetFlyBehavior(new FlyLikeRocket());
            mallardDuck.PerformFly();
        }
示例#17
0
        static void Main(string[] args)
        {
            // Strategy pattern
            IQuackable mallardDuck = new MallardDuck();
            IQuackable redheadDuck = new RedheadDuck();
            IQuackable rubberDuck  = new RubberDuck();

            duckCall(mallardDuck);
            duckCall(redheadDuck);
            duckCall(rubberDuck);

            Console.ReadKey();
        }
        public static void Run()
        {
            Duck mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();

            Duck model = new ModelDuck();

            model.PerformFly();
            model.flyBehavior = new FlyRockedPowered();
            model.PerformFly();
        }
    public static void Test()
    {
        Duck mallard = new MallardDuck();

        mallard.performQuack();
        mallard.performFly();

        Duck model = new ModelDuck();

        model.performFly();
        model.setFlyBehavior(new FlyRocketPowered());
        model.performFly();
    }
示例#20
0
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();

            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new Implementations.FlyRocketPower());
            model.PerformFly();
        }
示例#21
0
        public void Test2()
        {
            Duck mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();

            Duck model = new ModelDuck();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }
        public void TestDuckAdapter()

        {
            Duck mallard = new MallardDuck();

            Turkey duckAdapter = new DuckAdapter(mallard);



            Assert.AreEqual("Quack", duckAdapter.Gobble());

            Assert.AreEqual("I'm flying", duckAdapter.Fly());
        }
示例#23
0
        public static void Start()
        {
            var mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();

            var model = new ModelDuck();

            model.PerformFly();
            model.FlyBehavior = new FlyRocketPowered();
            model.PerformFly();
        }
示例#24
0
    static void Main(string[] args)
    {
        Duck mallard = new MallardDuck();

        mallard.Quack();
        mallard.Fly();

        Duck model = new ModelDuck();

        model.Fly();
        model.Fly = FlyRocketPowered;
        model.Fly();
    }
        public static void Main()
        {
            Duck mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();

            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
    static void Main(string[] args)
    {
        Duck mallard = new MallardDuck();

        mallard.PerformQuack();
        mallard.PerformFly();

        Duck model = new ModelDuck();

        model.PerformFly();
        model.SetFlyBehaviour(new FlyRocketPowered());
        model.PerformFly();
    }
    // Use this for initialization
    void Start()
    {
        Duck millard = new MallardDuck();

        millard.PerformQuack();
        millard.PerformFly();

        millard.SetFlyBehavior(new FlyNoWay());
        millard.SetQuackBehavior(new MuteQuack());

        millard.PerformQuack();
        millard.PerformFly();
    }
示例#28
0
        static void Main(string[] args)
        {
            Duck duck = null;

            duck = new BigYellow();
            duck = new MallardDuck();
            duck = new RubberDuck();
            duck = new SpaceDuck();

            duck.display();
            duck.fly();
            duck.quack();
            Console.ReadKey();
        }
示例#29
0
        static void Main(string[] args)
        {
            MallardDuck mallardDuck = new MallardDuck();
            WildTurkey  turkey      = new WildTurkey();

            TestDuck(mallardDuck);
            TestTurkey(turkey);
            IDuck turkeyAdapter = new TurkeyAdapter(turkey);

            TestDuck(turkeyAdapter);
            ITurkey duckAdapter = new DuckAdapter(mallardDuck);

            TestTurkey(duckAdapter);
        }
    static void Main()
    {
        MallardDuck   duck          = new MallardDuck();
        WildTurkey    turkey        = new WildTurkey();
        TurkeyAdapter turkeyAdapter = new TurkeyAdapter(turkey);

        System.Console.WriteLine("The tukey says...");
        turkeyAdapter.Quack();
        turkeyAdapter.Fly();

        System.Console.WriteLine("\nThe Duck says...");
        duck.Quack();
        duck.Fly();
    }
示例#31
0
        static void Main(string[] args)
        {
            Console.WriteLine("Simulador de patos");
            Console.WriteLine("------------------");

            Duck mallard = new MallardDuck();

            Console.WriteLine(mallard.PerformQuack());
            Console.WriteLine(mallard.PerformFly());

            Duck model = new ModelDuck();

            Console.WriteLine(model.PerformFly());
        }
        static void Main(string[] args)
        {
            Duck mallard = new MallardDuck();

            mallard.PerformQuack();
            mallard.PerformFly();
            mallard.Display();
            Console.WriteLine();
            Duck model = new ModelDuck();

            model.PerformFly();
            model.SetFlyBehavior(new FlyRocketPowered());
            model.PerformFly();
        }
示例#33
0
        public void Start()
        {
            logger.Info("Mallard Duck:");
            DuckHelper(new MallardDuck());

            logger.Info("Spaniel Duck:");
            DuckHelper(new SpanielDuck());

            logger.Info("Customized Duck:");
            var customizedDuck = new MallardDuck();

            customizedDuck.SetFly(new FlyHigh());
            DuckHelper(new MallardDuck());
        }
        static void Main(string[] args)
        {
            var mallard = new MallardDuck();
            mallard.Display();
            mallard.PerformFly();
            mallard.PerformQuack();

            var modelDuck = new ModelDuck();
            modelDuck.PerformFly();
            modelDuck.SetFlyBehavior(new FlyRocketPowered());
            modelDuck.PerformFly();

            Console.ReadKey(true);
        }
        static void Main(string[] args)
        {
            Duck duck = new MallardDuck();

            duck.PerformQuack();
            duck.PerformFly();

            duck = new ModelDuck();
            duck.PerformFly();
            duck.DuckFlyBehavior = new FlyRocketPowered();
            duck.PerformFly();

            Console.ReadLine(); // So the console window doesn't close immediately
        }
示例#36
0
        public static void Start()
        {
            var duck           = new MallardDuck();
            var turkey         = new WildTurkey();
            var turkeyLikeDuck = new TurkeyAdapter(turkey);

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

            turkey.Gobble();
            turkey.Fly();

            turkeyLikeDuck.Quack();
            turkeyLikeDuck.Fly();
        }
        static void Main(string[] args)
        {
            var mallard = new MallardDuck();
            mallard.PerformFly();
            mallard.PerformQuack();
            mallard.Display();
            mallard.Swim();

            var modelDuck = new ModelDuck();
            modelDuck.Display();
            modelDuck.PerformFly();
            modelDuck.FlyBehaviour = new FlyRocketPowered();
            modelDuck.PerformFly();
            Console.ReadLine();
        }
示例#38
0
        private static void Main(string[] args)
        {
            var duck = new MallardDuck();

            var turkey = new WildTurkey();
            var turkeyAdapter = new TurkeyAdapter(turkey);

            Console.WriteLine("The turkey says...");
            turkey.Gobble();
            turkey.Fly();

            Console.WriteLine("Duck says...");
            TestDuck(duck);

            Console.WriteLine("The turkeyAdapter says...");
            TestDuck(turkeyAdapter);

            Console.ReadLine();
        }
示例#39
0
 public void SetUp()
 {
     console = new ConsoleMock();
     duck = new MallardDuck();
 }
示例#40
0
        // Adapter pattern
        void quackTheDucks_Click(object sender, EventArgs e)
        {
            List<IQuackable> ducksToQuack = new List<IQuackable>();

            // Let's create some ducks - shows the beauty of interfaces
            MallardDuck mallardDuck = new MallardDuck();
            ducksToQuack.Add(mallardDuck);
            RubberDuck rubberDuck = new RubberDuck();
            ducksToQuack.Add(rubberDuck);
            DuckDecoy duckDecoy = new DuckDecoy();
            ducksToQuack.Add(duckDecoy);

            // Add a goose adapter to show the adapter pattern
            Goose goose = new Goose();
            GooseToDuckAdapter gooseToDuckAdapter = new GooseToDuckAdapter(goose);
            ducksToQuack.Add(gooseToDuckAdapter);

            OutputData(ducksToQuack);
        }