コード例 #1
0
        static void Main(string[] args)
        {
            var machine = new HotDrinkMachine();
            var drink   = machine.MakeDrink(AvailableDrink.Tea, 100);

            drink.Consume();

            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var machine = new HotDrinkMachine();

            while (true)
            {
                var drink = machine.MakeDrink();
                drink.Consume();
                WriteLine("... restarting.");
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: messnerdev/DesignPatterns
        static void Main(string[] args)
        {
            var point = PointWithFactoryMethods.NewPolarPoint(1, Math.PI / 2);

            Console.WriteLine(point);

            Point origin = Point.Origin;

            Console.WriteLine(origin);

            var machine = new HotDrinkMachine();

            machine.ListDrinks();
            var drink = machine.MakeDrink("Tea", 100);

            drink.Consume();
        }
コード例 #4
0
        static void Main(string[] args)
        {
            #region 内部工厂
            //Point2.Factory.NewCartisianPoint(1,2);
            //Point2.Factory.NewPolarPoint(1,2);

            #endregion

            #region 抽象工厂
            //IHotDrinkFactory factory = new TeaFactory();
            //factory.Produce().Consume();
            #endregion

            #region 抽象工厂与反射
            var hotDrinkMachine = new HotDrinkMachine();
            hotDrinkMachine.MakeDrink(HotDrinkMachine.AvailableDrink.Tea).Consume();
            #endregion
        }