Exemplo n.º 1
0
        static void Main(string[] args)
        {
            MakeCoffeeSingleton whiteCoffeeSingleton = new MakeCoffeeSingleton(new WhiteCoffee());

            // 中杯牛奶咖啡
            MediumCupCoffee mediumWhiteCoffee = new MediumCupCoffee();

            mediumWhiteCoffee.Make();

            // 大杯牛奶咖啡
            LargeCupCoffee largeCupWhiteCoffee = new LargeCupCoffee();

            largeCupWhiteCoffee.Make();

            MakeCoffeeSingleton blackCoffeeSingleton = new MakeCoffeeSingleton(new BlackCoffee());
            // 中杯原味咖啡
            MediumCupCoffee mediumBlackCoffee = new MediumCupCoffee();

            mediumBlackCoffee.Make();

            // 大杯牛奶咖啡
            LargeCupCoffee largeCupBlackCoffee = new LargeCupCoffee();

            largeCupBlackCoffee.Make();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //// Structure
            //Abstraction abstraction = new RefinedAbstraction();

            //abstraction.Implementor = new ConcreteImplementorA();
            //abstraction.Operation();

            //abstraction.Implementor = new ConcreteImplementorB();
            //abstraction.Operation();

            //Practical about making coffee;
            MakeCoffee blackCoffee = new BlackCoffee();
            MakeCoffeeSingleton.MakeCoffee = blackCoffee;

            Coffee large = new LargeCupCoffee();
            large.Make();

            Coffee medium = new MediumCupCoffee();
            medium.Make();

            MakeCoffee whiteCoffeee = new WhiteCoffee();
            MakeCoffeeSingleton.MakeCoffee = whiteCoffeee;

            Coffee large1 = new LargeCupCoffee();
            large1.Make();

            Coffee medium1 = new MediumCupCoffee();
            medium1.Make();

            Console.Read();
        }