1700483306
1700483307
代码清单36-13 场景类
1700483308
1700483309
public class Client{
1700483310
1700483311
public static void main(String[]args){
1700483312
1700483313
//获得事件分发中心
1700483314
1700483315
EventDispatch dispatch=EventDispatch.getEventDispathc();
1700483316
1700483317
//接受乞丐对事件的处理
1700483318
1700483319
dispatch.registerCustomer(new Beggar());
1700483320
1700483321
//接受平民对事件的处理
1700483322
1700483323
dispatch.registerCustomer(new Commoner());
1700483324
1700483325
//接受贵族对事件的处理
1700483326
1700483327
dispatch.registerCustomer(new Nobleman());
1700483328
1700483329
//建立一个原子弹生产工厂
1700483330
1700483331
ProductManager factory=new ProductManager();
1700483332
1700483333
//制造一个产品
1700483334
1700483335
System.out.println(”=====模拟创建产品事件========”);
1700483336
1700483337
System.out.println(“创建一个叫做小男孩的原子弹”);
1700483338
1700483339
Product p=factory.createProduct(“小男孩原子弹”);
1700483340
1700483341
//修改一个产品
1700483342
1700483343
System.out.println(”\n=====模拟修改产品事件========”);
1700483344
1700483345
System.out.println(“把小男孩原子弹修改为胖子号原子弹”);
1700483346
1700483347
factory.editProduct(p,“胖子号原子弹”);
1700483348
1700483349
//再克隆一个原子弹
1700483350
1700483351
System.out.println(”\n=====模拟克隆产品事件========”);
1700483352
1700483353
System.out.println(“克隆胖子号原子弹”);
1700483354
1700483355
factory.clone(p);
[
上一页 ]
[ :1.700483306e+09 ]
[
下一页 ]