外观模式(Façade)

外观模式(Facade pattern),是软件工程中常用的一种软件设计模式,它为子系统中的一组接口提供一个统一的高层接口,使得子系统更容易使用。

意图:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication19
{
    class Program
    {
        static void Main(string[] args)
        {
            new Computer().show();
            Console.ReadKey();

        }
    }

    class cpu
    {
        public void show() { Console.WriteLine("cpu 好"); }
    }

    class Memory {
        public void show() { Console.WriteLine("Memory 好"); }
    }


    class disk {
        public void show() { Console.WriteLine("disk 好"); }
    }



    class Computer {
        public void show() {
            new Memory().show();
            new disk().show();
            new cpu().show();
        }
    }


}

 

posted @ 2014-07-10 15:54  欢呼雀跃  阅读(160)  评论(0)    收藏  举报