package com.eyugame.modle; /** * 外观模式 * @author JYC506 * */ public class Computer { private Cpu cpu; private Disk disk; public Computer() { super(); this.cpu = new Cpu(); this.disk = new Disk(); } public void start() { System.out.println("computer start"); this.cpu.start(); this.disk.start(); } public void shudown() { this.disk.shudown(); this.cpu.shudown(); System.out.println("computer shutdown"); } public static void main(String[] args) { Computer computer=new Computer(); computer.start(); computer.shudown(); } } class Cpu { public void start() { System.out.println("cup start"); } public void shudown() { System.out.println("cup shutdown"); } } class Disk { public void start() { System.out.println("disk start"); } public void shudown() { System.out.println("disk shutdown"); } }
原文地址:http://blog.csdn.net/h348592532/article/details/45333833