代理模式
package com. atsgg. interfaceTest ;
public class StaticProxyTest {
public static void main ( String [ ] args) {
Star s = new Proxy ( new RealStar ( ) ) ;
s. confer ( ) ;
s. signContract ( ) ;
s. bookTicket ( ) ;
s. sing ( ) ;
s. collectMoney ( ) ;
}
}
interface Star {
void confer ( ) ;
void signContract ( ) ;
void bookTicket ( ) ;
void sing ( ) ;
void collectMoney ( ) ;
}
class RealStar implements Star {
public void confer ( ) {
}
public void signContract ( ) {
}
public void bookTicket ( ) {
}
public void sing ( ) {
System . out. println ( "明星:歌唱~~~" ) ;
}
public void collectMoney ( ) {
}
}
class Proxy implements Star {
private Star real;
public Proxy ( Star real) {
this . real = real;
}
public void confer ( ) {
System . out. println ( "经纪人面谈" ) ;
}
public void signContract ( ) {
System . out. println ( "经纪人签合同" ) ;
}
public void bookTicket ( ) {
System . out. println ( "经纪人订票" ) ;
}
public void sing ( ) {
real. sing ( ) ;
}
public void collectMoney ( ) {
System . out. println ( "经纪人收钱" ) ;
}
}