package study_02;
/*
*静态代理模式
*/
public class Test5 {
public static void main(String[] args) {
new WeddingCompany(new Me("dan")).happMarry();
}
}
//接口
interface Marry{
void happMarry();
}
//真实角色
class Me implements Marry{
private String name;
public Me(String name) {
this.name = name;
}
@Override
public void happMarry() {
System.out.println("marrying......" + name);
}
}
//代理角色
class WeddingCompany implements Marry{
private Me target;
public WeddingCompany(Me target) {
this.target = target;
}
@Override
public void happMarry() {
target.happMarry();
}
}