码迷,mamicode.com
首页 > 其他好文 > 详细

门面模式

时间:2017-02-03 23:52:39      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:add   []   span   blog   into   ssi   rgs   mode   client   

门面模式【Facade Pattern 】

interface LetterProcess{
    void writeContent(String content);
    void fillEnvelope(String address);
    void LetintoEnvelope();
    void sendLetter();
}

class LetterProcessImpl implements LetterProcess{
    @Override
    public void writeContent(String content) {
        System.out.println("fill content");
    }

    @Override
    public void fillEnvelope(String address) {
        System.out.println("fill address");
    }

    @Override
    public void LetintoEnvelope() {
        System.out.println("letintoenvelope");
    }

    @Override
    public void sendLetter() {
        System.out.println("send letter into envelope");
    }
}

class ModenPost{
    private LetterProcess letterProcess = new LetterProcessImpl();
    public void sendLetter(String content,String address){
        letterProcess.writeContent(content);
        letterProcess.fillEnvelope(address);
        letterProcess.LetintoEnvelope();
        letterProcess.sendLetter();
    }
}

public class Client{
    public static void main(String[] args) {
        ModenPost modenPost = new ModenPost();
        modenPost.sendLetter("content","address");
    }
}

过年第一更

门面模式

标签:add   []   span   blog   into   ssi   rgs   mode   client   

原文地址:http://www.cnblogs.com/mbky/p/6363663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!