静态代理模式
interface HuaweiProduct{
void sale(String productName);
}
class HuaweiCompany implements HuaweiProduct{
public void sale(String productName){
System.out.println("华为出品手机:"+productName);
}
}
class HuaweiCompanyProcy implements HuaweiProduct{
private HuaweiProduct huaweiProduct;
public HuaweiCompanyProcy(HuaweiProduct huaweiProduct){
this.huaweiProduct = huaweiProduct;
}
public void sale(String productName){
System.out.println("代理商销售前相关处理动作");
huaweiProduct.sale(productName);
System.out.println("代理商销售后相关处理动作");
}
}
public class test{
public static void main(String[] args) {
HuaweiCompanyProcy hcp = new HuaweiCompanyProcy(new HuaweiCompany());
hcp.sale("Mate10");
}
}