コード例 #1
0
        static void Main(string[] args)
        {
            //***** DUCKS
            Duck mallard = new MallardDuck();

            mallard.performQuack();
            mallard.performFly();
            mallard.display();
            mallard.setQuackBehaviour(new Squek());
            mallard.performQuack();

            Duck model = new ModelDuck();

            model.performQuack();
            model.display();
            model.setFlyBehavior(new FlyRocketPowered());
            model.performFly();

            Console.ReadKey();

            //***** CHOCOLATE FACTORY

            /*
             * ChocolateBoiler CB = ChocolateBoiler.getInstance();
             * CB.fill();
             * CB.boil();
             *
             * Console.WriteLine("Hello World! Is the chocolate factory boiled? "+ CB.isBoiled());
             * Console.ReadKey();
             */
        }
コード例 #2
0
ファイル: headFirstCh1.cs プロジェクト: xinyi88/Notes
    public static void Main(string[] args)
    {
        var f    = new FlyWithWings();
        var q    = new Squeak();
        var duck = new ModelDuck(f, q);

        duck.performFly();
        duck.display();
        duck.performQuack();
        //Your code goes here
        Console.WriteLine("Hello, world!");
    }