设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7391|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行+ R9 Z+ L2 b  `. C6 E3 z* \
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
0 y6 h6 f$ S2 i3 e+ {8 C9 I
1 e- v0 Y: x4 z) g. J似乎缺少了一个SwarmUtils的类,不知道怎么回事 8 N# R! r4 o% e
8 x- p! `* f: p0 J/ n; J
朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;3 ~6 x" ]: [1 H4 C

8 u  Z1 q, I' u6 G  ]1 qpublic class SwarmUtils {
- \# T  ]" S9 X* L. v  public static Selector getSelector(String name, String method) {
- B0 |, y* ^* R4 f6 [, F& r    Selector sel;$ F- S* z. @' B4 ?7 E4 ~
    try {$ x$ i$ b' t# f, r6 w; ?' w( U% C
      sel = new Selector(Class.forName(name), method, false);
# l, B1 l: w4 D+ q9 f    } catch (Exception e) {
# l( r2 Q; l) S5 O      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: A/ @! l4 L2 A' N0 w1 D      System.err.println(name + "." + method + " returns " + e.getMessage());
- }# Q: U1 V- h% I7 w      System.err.println("The process will be terminated.");
+ ]  z  |! |. P: f6 j+ X      System.exit(1);
' v5 v. U: P& }2 t4 ?2 n      return null;, G/ Y) r, G2 C
    }' R" K2 G* ^2 n' M
    return sel;+ q! P0 d$ e. c* H0 ~9 j
  }  G) G+ C* w5 g
3 v# b: u% M8 a' `4 s6 A
  public static Selector getSelector(Object obj, String method) {" n; h& {3 {0 {; u2 [8 W* _: N3 V* E; d) n
    Selector sel;1 B, r* M6 e1 C
    try {$ R3 w* S9 f7 m* T8 k( w$ j
      sel = new Selector(obj.getClass(), method, false);1 B6 p( m  B4 U* T- N9 L
    } catch (Exception e) {6 t) x( k' H1 C! l: l8 J
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "  e0 Q% @1 \4 t1 w) S' i
          + (obj.getClass()).getName() + ".");
& f0 E9 t0 _) j( X- G, n      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());4 W" u# `. T! e( R2 ]6 n9 _  Z, c; X
      System.err.println("The process will be terminated.");
6 Y' d* M3 ]8 M4 p* ^8 R# x      System.exit(1);
! U- p9 A8 T. K. O9 K: z      return null;: c: H7 W0 V/ |4 c7 ?9 @" n
    }  p) t$ R" j- l' r$ u
    return sel;
3 q( W' m# {% A; S1 p. L9 Z  }
6 O/ ~# z4 T. ~- |, t6 q}

评分

参与人数 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, 2025-5-10 11:43 , Processed in 2.437099 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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