码迷,mamicode.com
首页 > 编程语言 > 详细

java中23种设计模式之10-代理模式(Proxy pattern)

时间:2015-03-30 20:49:28      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!