//------------书店接口---------------------------
public interface Store {
public void sailBook();
}
//----------------具体的书店----------------------------------
public class RealStore implements Store {
public void sailBook() {
System.out.println("卖书");
}
}
//----------------代理商--------------------------------
public class ProxyStore implements Store{
private RealStore realSubject;
public void sailBook() {
dazhe();
if(realSubject == null) {
realSubject = new RealStore();
}
realSubject.sailBook();
give();
}
public void dazhe() {
System.out.println("打折");
}
public void give() {
System.out.println("赠送代金券");
}
}
//--------------------测试类-------------------------------------------
public class MainClass {
public static void main(String[] args) {
ProxyStore proxySubject = new ProxyStore();
proxySubject.sailBook();
}
}