标签:doc 允许 tle oid 小明 ann ati ide comm
public interface Person{
public void eat();
}
public class Boy implements Person
{
private String name; // 姓名
public Boy(String name) {
this.name = name;
}
@Override
public void eat
() {
System.out.println(name+"吃饭不能吃菜");
}
}
public class Man implements Person{
private Person
person; // 被代理对象
public Man
(Person
person
) {
this.person
= person
;
}
@Override
public void eat
() {
person
.eat
();
System.out.println("允许吃菜了");
}
}
public class ProxyTest{
public static void main(String[] args) {
Person p
erson
= new Man
(new Boy("小明"));
p
erson
.eat();
}
}
标签:doc 允许 tle oid 小明 ann ati ide comm
原文地址:http://www.cnblogs.com/hututu/p/6489157.html