package com.guigu.day15.java1;标签:Star,void,代理,模式,System,Override,public,out From: https://www.cnblogs.com/jiaxing-java/p/16942265.html
public class StaticProxyTest {
public static void main(String[] args) {
Proxy p = new Proxy(new RealStar());
p.confer();
p.signContract();
p.sing();
p.bookTicket();
p.collectMoney();
}
}
interface Star{
void confer();
void signContract();
void bookTicket();
void sing();
void collectMoney();
}
// 被代理类
class RealStar implements Star {
@Override
public void confer() {
}
@Override
public void signContract() {
}
@Override
public void bookTicket() {
}
@Override
public void sing() {
System.out.println("明星:唱歌");
}
@Override
public void collectMoney() {
}
}
// 代理类
class Proxy implements Star{
private Star star;
// Star s = new RealStar();
public Proxy() {
}
public Proxy(Star star) {
this.star = star;
}
@Override
public void confer() {
System.out.println("经纪人面谈");
}
@Override
public void signContract() {
System.out.println("经纪人签合同");
}
@Override
public void bookTicket() {
System.out.println("经纪人订票");
}
@Override
public void sing() {
star.sing();
}
@Override
public void collectMoney() {
System.out.println("经纪人收钱");
}
}