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();
    只是查找方便的总结
  • 相关阅读:
    sshpass连接主机以及执行命令
    elk集群配置并破解x-pack
    socket实现简单通信会话
    docker容器跨宿主机通信
    docker运行wordpress
    centos7 利用docker运行nginx项目
    docker容器基础命令
    docker镜像基础命令
    vue中使用延时加载
    less
  • 原文地址:https://www.cnblogs.com/qutao125/p/14607805.html
Copyright © 2011-2022 走看看