package com.lonton.designpatterns;
interface SluttyWife
{
public void seduceMen();
public void happyWithMen();
}
class HouseWife implements SluttyWife
{
@Override
public void seduceMen()
{
// TODO Auto-generated method stub
System.out.println("HouseWifeOne secude men, such as making some sexy poses ...");
}
@Override
public void happyWithMen()
{
// TODO Auto-generated method stub
System.out.println("HouseWifeOne is happy with man ...");
}
}
class BussinessAgent implements SluttyWife
{
SluttyWife sluttyWife;
public BussinessAgent()
{
this.sluttyWife = new HouseWife();
}
public BussinessAgent(SluttyWife sluttyWife)
{
super();
this.sluttyWife = sluttyWife;
}
@Override
public void seduceMen()
{
// TODO Auto-generated method stub
sluttyWife.seduceMen();
}
@Override
public void happyWithMen()
{
// TODO Auto-generated method stub
sluttyWife.happyWithMen();
}
}
public class ProxyTest
{
public static void main(String[] args)
{
SluttyWife sluttyWife = new HouseWife();
BussinessAgent buAgent = new BussinessAgent(sluttyWife);
buAgent.seduceMen();
buAgent.happyWithMen();
}
}
Proxy 代理模式
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.