设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10519|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行) {" Z* i" |+ H+ {2 `
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
" b* x% `, @. {. U# P2 V& e# ^
' Z6 A7 U% y1 p+ F. p* a$ G似乎缺少了一个SwarmUtils的类,不知道怎么回事
- \1 j/ G  h' n& O% k# ?6 d% J( c, j9 K/ p0 \- G3 k7 s* u0 e5 J
朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;% A, A) v: [! k& ^

9 y7 J: ^3 `# a& h1 I0 ^0 z1 `& Tpublic class SwarmUtils {+ O9 a% [. ?' t8 B! ~, \
  public static Selector getSelector(String name, String method) {3 F! T% A' u6 ]: A: M) _6 B# R( [
    Selector sel;1 U. U) B. P- X: x" w
    try {! ]8 s- P6 V6 s* R! ~# e, R# d
      sel = new Selector(Class.forName(name), method, false);
5 ]5 w" }: E( h$ m    } catch (Exception e) {0 l$ t9 |7 g! `" t( Z3 J) J% z
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
; l$ |& J5 k; O! c9 i+ C6 P9 S5 n      System.err.println(name + "." + method + " returns " + e.getMessage());9 F9 \; j9 }9 @2 b. [
      System.err.println("The process will be terminated.");" z. \0 }4 ~. e+ Y% x8 e4 e
      System.exit(1);+ I) Z" a! X( |5 B1 R( l
      return null;0 J$ `5 R& H" E$ Y' r" A
    }
1 B: J* g% |& c" k    return sel;" h1 c5 G& i1 C2 ^' G( p" M
  }
! G! R) z& t# u# h& `7 ?5 a- ?* ]. x: X* M/ q( @7 I
  public static Selector getSelector(Object obj, String method) {+ n) b0 [" n; ~
    Selector sel;
, W6 L6 R, a2 w2 N) `1 T% U2 Z    try {
% Z# W# x0 J" X      sel = new Selector(obj.getClass(), method, false);3 {& F/ v8 A% n2 u
    } catch (Exception e) {
+ d4 S) j* y& X      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "- E2 l. w4 `7 I& f0 R
          + (obj.getClass()).getName() + ".");
$ u( `& ~$ X, c      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());' O" c1 }: W+ g; F6 @2 o/ q
      System.err.println("The process will be terminated.");
  B* X6 U7 w0 i) K$ b3 H      System.exit(1);
! q. Y1 r8 R) Q% t) {      return null;
4 [) p1 ~  m( K  A; @" D    }
$ H! |- Q; l. w" D  B5 Z+ g    return sel;
6 ]! e% u" M& i! R1 \( o' q8 R1 }1 }6 k  }$ i8 W- c( ^: G  L  C1 i
}

评分

参与人数 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-8-28 19:51 , Processed in 0.017802 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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