zoukankan      html  css  js  c++  java
  • 23种设计模式学习之外观模式

        public class CPU {  
              
            public void startup(){  
                System.out.println("cpu startup!");  
            }  
              
            public void shutdown(){  
                System.out.println("cpu shutdown!");  
            }  
        }  
    
        public class Memory {  
              
            public void startup(){  
                System.out.println("memory startup!");  
            }  
              
            public void shutdown(){  
                System.out.println("memory shutdown!");  
            }  
        }  
    
        public class Disk {  
              
            public void startup(){  
                System.out.println("disk startup!");  
            }  
              
            public void shutdown(){  
                System.out.println("disk shutdown!");  
            }  
        }  
    
        public class Computer {  
            private CPU cpu;  
            private Memory memory;  
            private Disk disk;  
              
            public Computer(){  
                cpu = new CPU();  
                memory = new Memory();  
                disk = new Disk();  
            }  
              
            public void startup(){  
                System.out.println("start the computer!");  
                cpu.startup();  
                memory.startup();  
                disk.startup();  
                System.out.println("start computer finished!");  
            }  
              
            public void shutdown(){  
                System.out.println("begin to close the computer!");  
                cpu.shutdown();  
                memory.shutdown();  
                disk.shutdown();  
                System.out.println("computer closed!");  
            }  
        }  
    
    public class Demo {
        public static void main(String[] args) {
            Computer computer = new Computer();
            computer.startup();
            computer.shutdown();
        }
    }
    
  • 相关阅读:
    Postman测试写法的问题
    Spring Cloud
    Swagger2构造RESTful API开发Java Web
    web前端三大框架(主流Vue.js)
    zookeeper
    分布式服务介绍
    2019年java技术大盘点
    refusing to merge unrelated histories
    PPT制作不加班的十个小窍门
    如何快速完成一份学术型PPT
  • 原文地址:https://www.cnblogs.com/2nao/p/8296785.html
Copyright © 2011-2022 走看看