打字猴:1.70046996e+09
1700469960
1700469961 增加了一个Police类,负责对信件进行检查,如代码清单23-6所示。
1700469962
1700469963 代码清单23-6 信件检查类
1700469964
1700469965 public class Police{
1700469966
1700469967 //检查信件,检查完毕后警察在信封上盖个戳:此信无病毒
1700469968
1700469969 public void checkLetter(ILetterProcess letterProcess){
1700469970
1700469971 System.out.println(letterProcess+“信件已经检查过了……”);
1700469972
1700469973 }
1700469974
1700469975 }
1700469976
1700469977 我们再来看一下封装类ModenPostOffice的变更,它封装了这部分的变化,如代码清单23-7所示。
1700469978
1700469979 代码清单23-7 扩展后的现代化邮局
1700469980
1700469981 public class ModenPostOffice{
1700469982
1700469983 private ILetterProcess letterProcess=new LetterProcessImpl();
1700469984
1700469985 private Police letterPolice=new Police();
1700469986
1700469987 //写信,封装,投递,一体化了
1700469988
1700469989 public void sendLetter(String context,String address){
1700469990
1700469991 //帮你写信
1700469992
1700469993 letterProcess.writeContext(context);
1700469994
1700469995 //写好信封
1700469996
1700469997 letterProcess.fillEnvelope(address);
1700469998
1700469999 //警察要检查信件了
1700470000
1700470001 letterPolice.checkLetter(letterProcess);
1700470002
1700470003 //把信放到信封中
1700470004
1700470005 letterProcess.letterInotoEnvelope();
1700470006
1700470007 //邮递信件
1700470008
1700470009 letterProcess.sendLetter();
[ 上一页 ]  [ :1.70046996e+09 ]  [ 下一页 ]