设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9439|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行
: S+ H4 ]+ V. h) Fsel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
) e* R5 h0 ^; X% o5 \' C; q0 O# X9 H5 g" L% p& w0 r
似乎缺少了一个SwarmUtils的类,不知道怎么回事 4 A8 B' k# M/ A

/ s& c" B5 a' X, g朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;  ]0 O' [: G  L% O, o

: s/ ^5 k$ _2 V8 wpublic class SwarmUtils {  h2 Y7 E+ v& t- N4 }+ J1 O
  public static Selector getSelector(String name, String method) {
  k3 c, N1 n# A    Selector sel;% H4 S0 x- |7 M" b' ]7 h( t
    try {
! @1 ^5 {2 U. [( v" e. j3 |      sel = new Selector(Class.forName(name), method, false);
5 X' e/ J1 `  l& N, [% c    } catch (Exception e) {, s0 o4 \) I8 |3 L
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");; g$ d7 F. h; K/ [. Q# P9 D
      System.err.println(name + "." + method + " returns " + e.getMessage());
% b; X8 a2 b" O8 M+ {  t& g      System.err.println("The process will be terminated.");2 K- a" D0 \1 z1 |' p
      System.exit(1);
/ L7 A1 J+ V& l8 f      return null;( p1 z: K" v/ K6 g7 j! n/ D
    }* n9 A& O9 @* k0 C
    return sel;6 ^1 B6 p6 @) W# f# }1 z
  }" L& ~2 |3 |4 u( f; o

" ?& Q3 Q1 x6 B0 P4 Q/ `' H/ r  public static Selector getSelector(Object obj, String method) {, s2 I( R% |$ g" V$ k
    Selector sel;, R- ?& E. P3 p: h( e4 J. q6 {
    try {! x8 w9 T0 P7 m7 U+ L
      sel = new Selector(obj.getClass(), method, false);: o. \* H, A$ l9 m/ s0 v. A  J
    } catch (Exception e) {8 Y% t% I7 s1 m5 F! S, X
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class ", k* \! K8 |6 B8 T, z, |
          + (obj.getClass()).getName() + ".");2 r, R( [5 J* {8 Z; ^4 v( ?
      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());( b3 V7 B4 L2 r! h* M
      System.err.println("The process will be terminated.");* K5 e7 n, v) _/ O2 b& C* z# u9 T
      System.exit(1);) S& x) {# ^% H
      return null;
/ B6 s2 m0 F' ?* g    }: v( a6 q* i% e/ C: R( \" U
    return sel;6 `2 V$ P. Y2 [4 x6 D* [/ U7 c
  }
- j/ X' t% t* a2 F9 z}

评分

参与人数 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-4-24 14:02 , Processed in 0.016316 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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