设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9721|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行
  f7 Q4 j) Q. b9 S0 q6 w; R5 |! msel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
4 `4 t" r7 m1 x5 ]' I& K( v; X; H, f4 d7 I' J$ \3 I
似乎缺少了一个SwarmUtils的类,不知道怎么回事 % ]" T! p3 C  d8 Q

5 S% M& v3 R7 k# v6 r  H' @8 a7 L朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;4 y4 {8 R. S1 d. p2 f& F! I- G( ]

* E( m8 q& ^. P& H7 e. Epublic class SwarmUtils {) E+ o( f% m! d  L# I; L
  public static Selector getSelector(String name, String method) {8 F, h& d" ~$ s. F. g
    Selector sel;) k8 i4 g1 E- }) v; ]$ V* ?: c
    try {
# K0 u6 d6 ?9 r; `      sel = new Selector(Class.forName(name), method, false);) i' [. Z3 D- y, R; a( ]: T9 j1 K
    } catch (Exception e) {
7 A2 M4 r- f" C( T6 g! Z6 \; ]      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
3 L" ~" D9 i, i0 Z# \6 e- [      System.err.println(name + "." + method + " returns " + e.getMessage());7 X2 m1 p7 X4 i3 b$ i
      System.err.println("The process will be terminated.");' w$ G# F( p. d) u+ s
      System.exit(1);
4 k; S2 F. h) F4 E* ]4 {! x0 R      return null;
! V7 B9 X  }' E    }  t% G- Y; M( f" R
    return sel;1 ?5 G3 ?# Y" Q
  }
9 p8 k1 x* v/ B) u7 i. e- w. G; ]8 q! u4 V
  public static Selector getSelector(Object obj, String method) {; _* ^+ `1 Z/ |
    Selector sel;5 [1 `+ X  M. W* s
    try {* u, }/ b" k1 D# ~$ ?& r
      sel = new Selector(obj.getClass(), method, false);
( Z( G3 u" d7 m# V  c" n  u9 }    } catch (Exception e) {# g" X5 G. E' A: p& V
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "5 ^1 o2 y8 x: ?6 |5 L: M5 Y
          + (obj.getClass()).getName() + ".");
$ Y( f8 o/ t$ f' E( j      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());; i6 w% B( g  S' Y+ Z3 E
      System.err.println("The process will be terminated.");7 k1 {8 m4 b# e- L) J/ T" `, L
      System.exit(1);
9 _6 Y) a. F# F, T* `7 Q6 A      return null;2 `- Q; q: k( L" u
    }9 k. Q2 w, o+ m
    return sel;
: ]) n1 b& |( Q; G  }
! ?& b; ?/ q: _# ?3 {}

评分

参与人数 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-5-30 18:57 , Processed in 0.014910 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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