Ejemplo n.º 1
0
        public void BridgeTest()
        {
            {
                var a = new ConcreteImplementorA();
                var b = new ConcreteImplementorB();

                var ra = new RefinedAbstractionA();
                var rb = new RefinedAbstractionB();
                ra.SetImplementor(a);
                ra.Operation();

                ra.SetImplementor(b);
                ra.Operation();
            }

            {
                var black = new BlackCoffee();
                var white = new WhiteCoffee();

                var large = new LargeCupCoffee(black);
                large.Make();
                large.SetCoffee(white);
                large.Make();

                var medium = new MediumCupCoffee(black);
                medium.Make();
                medium.SetCoffee(white);
                medium.Make();
            }
        }
Ejemplo 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();
        }