涉及到代理这个词,就能想到国内外代购。
当你要买国外的产品,就会想到,电商平台或者是国外代购。
静态代理的概念也是如上。
假如你要买一款国外线下才有的鞋。那么你去购买的这个动作,就由平台来完成。
package com.ht.Thread;
public class ThreadDemo5 {
public static void main(String[] args) {
new EBay(new You()).BuyShoe();
}
}
interface Buy{
void BuyShoe();
}
class You implements Buy{
@Override
public void BuyShoe() {
System.out.println("突然想买一双鞋,那我去Ebay看看");
}
}
class EBay implements Buy{
private Buy target;
public EBay(Buy target){
this.target = target;
}
@Override
public void BuyShoe() {
this.target.BuyShoe();
System.out.println("收到订单");
System.out.printf("派送订单");
}
}
代码思路:当顾客有了想法,直接去电商平台下单,等着收货就行。
购买的动作由平台来执行。