Rent接口
public interface Rent {
public void rent();
}
Host类
public class Host implements Rent {
@Override
public void rent() {
System.out.println(“房东要出租房子”);
}
}
Client类
public class Client {
public static void main(String[] args) {
Host host=new Host();
Proxy proxy=new Proxy(host);
proxy.rent();
}
}
Proxy类
public class Proxy {
private Host host;
public Proxy() {
}
public Proxy(Host host) {
this.host = host;
}
public void rent(){
seeHouse();
fare();
hetong();
host.rent();
}
public void seeHouse(){
System.out.println("中介带你看房");
}
public void fare(){
System.out.println("收中介费");
}
public void hetong(){
System.out.println("签租赁合同");
}
}