zoukankan      html  css  js  c++  java
  • PHP设计模式-抽象工厂

    interface technology{
        public function top();
    }
    interface humanity{
        public function most();
    }
    
    
    class american implements technology{
        public function top(){
            echo '芯片';
        }
    }
    
    class chinese implements technology{
        public function top(){
            echo  '5G';
        }
    }
    
    
    class americanMan implements humanity{
        public function most(){
            echo '性情开朗、 乐于交际、 不拘礼节';
        }
    }
    
    
    class chinaMan implements  humanity{
        public function most(){
            echo '厚德开放与包容';
        }
    }
    
    
    
    interface compareFactory{
        public function compareTeco();
        public function compareHumanity();
    }
    
    
    class americanFactory implements compareFactory{
        public function compareTeco(){
            return new american();
        }
        
        public function compareHumanity(){
            return new americanMan();
        }
    }
    
    
    class chineseFactory implements compareFactory{
        public function compareTeco(){
            return new chinese();
        }
        
        public function compareHumanity(){
            return new chinaMan();
        }
    }
    
    
    $china = new chineseFactory();
    $chinaTeco = $china->compareTeco();
    $chinaTeco->top();
    $chinaHumanty  = $china->compareHumanity();
    $chinaHumanty->most();
    只是查找方便的总结
  • 相关阅读:
    JAVA
    JAVA
    软件工程概论
    大道至简杂记
    InvokeRequired和Invoke
    C#代码:用事件模式实现通知
    VS 2012 C#快捷键
    error LNK2026: 模块对于 SAFESEH 映像是不安全的
    写EXCEL(csv 可以用EXECEL打开,逗号分列隔符)
    防止界面卡顿
  • 原文地址:https://www.cnblogs.com/qutao125/p/14607805.html
Copyright © 2011-2022 走看看