Facade--门面模式
interface LetterProcess {public void writeContext(String context);public void fillEnvelope(String address);public void letterIntoEnvelope();public void sendLetter();}class PersonWriteLetter implements LetterProcess {@Overridepublic void writeContext(String context) {// TODO Auto-generated method stubSystem.out.println("write the context:" + context);}@Overridepublic void fillEnvelope(String address) {// TODO Auto-generated method stubSystem.out.println("fill Envelope with address:" + address);}@Overridepublic void letterIntoEnvelope() {// TODO Auto-generated method stubSystem.out.println("put letter into Envelope");}@Overridepublic void sendLetter() {// TODO Auto-generated method stubSystem.out.println("send letter");}}public class Facade {LetterProcess letterProcess = new PersonWriteLetter();Police police = new Police();public void sendLetter(String context, String address) {letterProcess.writeContext(context);letterProcess.fillEnvelope(address);letterProcess.letterIntoEnvelope();//任何对LetterPress操作的过程可以放在门面中。如,警察检查信件police.checkLetter(letterProcess);letterProcess.sendLetter();};}class Police{void checkLetter(LetterProcess letterProcess){}}/** * 4.门面模式Facade */System.out.println("***********4.门面模式***********");Facade facade = new Facade();facade.sendLetter("I Love u", "No.5 Street");