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
时间: 2024-10-12 08:56:28