标签:
interface Station
{
void sellTickets();
}
class TrainStation implements Station
{
public TrainStation()
{
}
public void sellTickets()
{
System.out.println("TrainStation selling tickets");
}
}
class TrainStationProxy implements Station
{
private TrainStation aTrainStation=null;
public TrainStationProxy()
{
aTrainStation=new TrainStation();
}
public void sellTickets()
{
aTrainStation.sellTickets();
}
}
public class ProxyPatternTest
{
public static void main(String[] args)
{
TrainStationProxy aTrainStationProxy=new TrainStationProxy();
aTrainStationProxy.sellTickets();
}
}
///////////////////////////////////////////
输出结果:
TrainStation selling tickets
java中23种设计模式之10-代理模式(Proxy pattern)
标签:
原文地址:http://www.cnblogs.com/wudymand/p/4379019.html