设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10077|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行( r" M% s( s! Z9 y6 i% ^
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
- u' \' S7 ^1 D& E0 O( b# }2 p0 b
似乎缺少了一个SwarmUtils的类,不知道怎么回事 + H' L1 L1 ?, L2 {8 H* l) h6 \" F$ x

' H; ~1 d& @3 Q朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;0 S+ n* ~8 j) n$ ^! L$ |: @3 W

/ m7 x& C/ _7 R/ C. _* lpublic class SwarmUtils {
; a8 d  R/ M9 D0 b! f* Q  public static Selector getSelector(String name, String method) {
7 E3 {+ d" r3 m    Selector sel;
" p1 ?% @, h% w: Q) \    try {
3 v$ J+ {7 x. `      sel = new Selector(Class.forName(name), method, false);! d. F8 v, o6 D
    } catch (Exception e) {6 d& L7 h" K9 s& {1 I6 O4 b
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
. C$ C6 p6 Y! q# b      System.err.println(name + "." + method + " returns " + e.getMessage());
3 d9 M- b9 H, p! M. z: h; O      System.err.println("The process will be terminated.");1 e0 S" i' n/ Y3 S9 f& c' O9 [& _
      System.exit(1);
' B6 V9 I, h# }( c) F+ m" \      return null;
  G' u/ H1 x8 y3 g/ L    }
! c; d5 i/ S2 e0 V' N    return sel;; m. U, X4 c8 A+ B9 `- ^. [! G( v
  }
& V) c8 @: u+ m0 y% L1 K# S: H% V( ?' [# k" I$ N
  public static Selector getSelector(Object obj, String method) {; @- i4 Y' t6 N7 V
    Selector sel;
  [0 ]0 ^& |% U    try {% @3 v% h4 a2 f5 [# K, X. H
      sel = new Selector(obj.getClass(), method, false);
' l* m1 w, ]! R9 G    } catch (Exception e) {6 s  Y# D+ f! @6 P7 v6 n
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "  V0 `( S( v$ ?( f2 \' d8 s6 A
          + (obj.getClass()).getName() + ".");. G# v. z* U1 U! _+ A
      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());9 c- m& u) D! j, |- U: L
      System.err.println("The process will be terminated.");
6 ?& u  t* F- ~! W9 o* q0 @      System.exit(1);9 u( G; ]# y/ s7 K" [
      return null;: g- z: ]( E/ y% [, r1 S! w
    }! r+ q8 Y  m/ p' Z
    return sel;
* S4 L! m( Y5 r3 T( x9 F8 `8 B  }
# E( l% A. s) k}

评分

参与人数 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-15 03:56 , Processed in 0.017591 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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