设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10025|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行
" T& ?* \. E% _6 Vsel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
  O- }% Q5 p. a4 N6 e% l4 k! c* {" k! t1 B3 R7 r$ N$ w: A  z
似乎缺少了一个SwarmUtils的类,不知道怎么回事 4 p0 y2 X0 {( d" c) X/ ]
# k7 z' x  E9 I7 W* f: t
朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;" a' I4 F9 N- [  h

* m! J' y1 _$ ?' @. S  S) o' p, wpublic class SwarmUtils {
4 F- p. v- S" o" H  public static Selector getSelector(String name, String method) {* u5 V6 I! m0 u. `" a0 G; V+ E
    Selector sel;7 Y4 c6 Q; L" m( T
    try {" p) \( o4 e! g7 c) e! l8 c. O
      sel = new Selector(Class.forName(name), method, false);
1 Z) l% Z# i/ K    } catch (Exception e) {
" I8 X1 K. D* d9 m) Q* b9 o; X      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");0 R: j& {% E! Z0 w( ^9 r! u% R
      System.err.println(name + "." + method + " returns " + e.getMessage());) ?7 a% Q2 n+ m: @, |
      System.err.println("The process will be terminated.");
* ?. g: ?, J; p  k: b8 r5 [      System.exit(1);' ]; r6 Q' g8 {) w
      return null;
7 D+ ]7 }  M. ]3 e: W    }6 Z9 v) x2 f  E! z- P
    return sel;
+ N9 n3 i& g3 U5 e1 a) V  }
; l* V- {9 g1 E: W  h# q. C
0 o6 ^3 A' c, S$ p7 u! r) }  public static Selector getSelector(Object obj, String method) {
. S3 h* U6 ]% f/ U+ T    Selector sel;
: H- Y6 r( B( i' J, F    try {& q* M* m7 b% q( D) j+ \, i
      sel = new Selector(obj.getClass(), method, false);
$ n4 u* R( }; H) u3 P- t% E  A    } catch (Exception e) {. }; X2 r% `! s8 w8 L2 F5 b
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "  J% I5 Y5 i5 \  |. D7 q0 D
          + (obj.getClass()).getName() + ".");
: J* f1 i6 v% |+ Q1 u0 @      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());& ~* K- s, K. K8 ~4 q! {" A
      System.err.println("The process will be terminated.");
+ j$ C! Q6 b' t* Q6 C7 Q      System.exit(1);
2 i" p" L& E" B) T, _* Z" c9 u5 l. Y      return null;$ J2 x1 ?' |2 W: C& i& c) ]$ d
    }
" `. ]* g+ D, m0 B9 ?" [, i! V    return sel;
' Y3 P6 {; N6 g( f! ~2 C2 v  }  g6 Y2 u# Q+ ^) U3 Y7 B
}

评分

参与人数 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-7-9 09:47 , Processed in 0.014575 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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