设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9154|回复: 7

[交流] 科学网于同奎先生的源程序

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行
' T" n- A! `* c# t9 Csel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行" `+ V6 q- V2 H; a
; x0 y# t9 p8 ~0 j' S
似乎缺少了一个SwarmUtils的类,不知道怎么回事 9 @3 Y/ F1 `0 X& K
3 N$ z; G* z% M0 i& z
朋友们给个反馈??

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

评分

参与人数 1仿真币 +12 +1 收起 理由
苘苘 + 12 + 1

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;
& m: f. g+ g* r/ X1 Y
1 N! D7 e. R+ x! l) Ppublic class SwarmUtils {
8 ]5 ^: p' j" e5 L9 K  public static Selector getSelector(String name, String method) {9 K- g$ \/ q' g7 \) \
    Selector sel;
7 x6 }) m0 y+ \    try {
$ i( R5 ?& ]4 _% K      sel = new Selector(Class.forName(name), method, false);
" T' O4 I9 c: l    } catch (Exception e) {* B5 G0 A. L8 h. j
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
0 W8 t2 R" G0 }, e6 T      System.err.println(name + "." + method + " returns " + e.getMessage());& w; p4 N9 _  h( ?" i0 V) N/ n# w
      System.err.println("The process will be terminated.");
4 @+ }+ }# r0 W9 Z      System.exit(1);
. O) x* f5 F9 w8 `) q      return null;3 y: E* j3 Y9 p& o1 c
    }* y# w; E! {4 w0 `. D4 ~
    return sel;
5 H6 d5 @4 [' T  }
  H1 z' b* m$ @! h8 q6 B, i+ z1 Q  u. Q* @( n: Y( Z7 v3 s
  public static Selector getSelector(Object obj, String method) {& v' N; F+ @, k: c
    Selector sel;% l/ ?. I2 v$ m. u. [' I
    try {
6 o$ y* d/ R& b) e- D2 \      sel = new Selector(obj.getClass(), method, false);
" ~( m5 m: E. @: m' t! M6 j! I    } catch (Exception e) {; w, D0 U, ^- a+ q. H  i
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "/ [# l# g6 g2 m1 s: D  J1 L
          + (obj.getClass()).getName() + ".");
4 h3 G# f1 a$ l- X$ O% E      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());9 I: U; u/ ?4 Y, b8 q  c. J
      System.err.println("The process will be terminated.");: |" A$ W( H% Q  i) W
      System.exit(1);
6 c+ u2 b% v8 }# F      return null;
5 {% E! R# \+ N& e0 Q! f  n    }
) `( E2 E4 i$ F: `* j( a/ i( G! W" ^    return sel;0 c+ P% O1 J1 v" `) N: H$ `
  }
& r+ u& c7 Q+ Z$ ~2 a}

评分

参与人数 1仿真币 +21 +1 收起 理由
苘苘 + 21 + 1 我很赞同

查看全部评分

发表于 2008-11-20 19:49:58 | 显示全部楼层
very good.
发表于 2008-11-28 11:12:43 | 显示全部楼层
这个……在SimpleBug的代码中自带了一个SwarmUtils的类……答案如2楼所示……
发表于 2009-3-12 14:52:51 | 显示全部楼层

谢谢

学习学习
发表于 2009-12-2 20:20:58 | 显示全部楼层
请问一下代码是添加在哪里的啊?
发表于 2012-5-22 10:31:21 | 显示全部楼层
是单独建立一个新的JAVA文件,文件名为SwarmUtils.java,然后把上述代码复制进去就可以了
发表于 2013-1-25 12:27:29 | 显示全部楼层
学习。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-3-23 14:00 , Processed in 0.016158 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表