JAVA学習--反射の静的エージェントモード
4572 ワード
1 //
2 //
3 interface ClothFactory{
4 void productCloth();
5 }
6 //
7 class NikeClothFactory implements ClothFactory{
8
9 @Override
10 public void productCloth() {
11 System.out.println("Nike ");
12 }
13 }
14 //
15 class ProxyFactory implements ClothFactory{
16 ClothFactory cf;
17 // ,
18 public ProxyFactory(ClothFactory cf){
19 this.cf = cf;
20 }
21
22 @Override
23 public void productCloth() {
24 System.out.println(" , $1000");
25 cf.productCloth();
26 }
27
28 }
29
30 public class TestClothProduct {
31 public static void main(String[] args) {
32 NikeClothFactory nike = new NikeClothFactory();//
33 ProxyFactory proxy = new ProxyFactory(nike);//
34 proxy.productCloth();
35 }
36 }