示例#1
0
文件: Program.cs 项目: P3ar1baron/GoF
        static void Main(string[] args)
        {
            var newElectricitySystem = new NewElectricitySystem();

            ElectricityConsumer.ChargeNotebook(newElectricitySystem);

            var oldElectricitySystem = new OldElectricitySystem();
            var adapter = new Adapter(oldElectricitySystem);

            ElectricityConsumer.ChargeNotebook(adapter);
        }
示例#2
0
        static void Main(string[] args)
        {
            var newElectricitySystem = new NewElectricitySystem();
            var oldElectricitySystem = new OldElecticitySystem();

            ElectricityConsumer.ChargePhone(newElectricitySystem);

            var adapter = new Adaprer(oldElectricitySystem);

            ElectricityConsumer.ChargePhone(adapter);
            Console.ReadKey();
        }
示例#3
0
        public static void Main()
        {
            // 1)
            // Ми можемо і надалі користувати нашою новою системою
            var newElectricitySystem = new NewElectricitySystem();

            ElectricityConsumer.ChargeNotebook(newElectricitySystem);

            // 2)
            // Ми повинні адаптуватися до старої системи, використовуючи адаптер
            var oldElectricitySystem = new OldElectricitySystem();
            var adapter = new Adapter(oldElectricitySystem);

            ElectricityConsumer.ChargeNotebook(adapter);
        }