设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9838|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行4 H8 N3 z6 x! `
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
% B$ {+ ]3 b! i4 o0 J9 O( ^' ?2 j# D/ ~( d8 `, `
似乎缺少了一个SwarmUtils的类,不知道怎么回事
) t: K5 _& i2 |  A/ ]) M+ Y9 c' {4 O  {
朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;
; Z/ K1 q2 S9 _! j
0 I" H& g+ q3 u, C+ X5 Kpublic class SwarmUtils {7 y, e% G) ~( m* `$ n1 ^' ]
  public static Selector getSelector(String name, String method) {, J" ?. ~3 W- g
    Selector sel;8 [; {" d$ R' \; ?3 l
    try {3 X/ I$ U$ W/ S- u5 d6 p5 m
      sel = new Selector(Class.forName(name), method, false);
9 w. v- m" H* f- m    } catch (Exception e) {
' i8 f1 }( f; E. }3 c      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
: o3 F! B4 L# s4 _+ A! a# a2 J. ]9 B1 D      System.err.println(name + "." + method + " returns " + e.getMessage());. J) y8 Q+ h; D8 x/ M, ~
      System.err.println("The process will be terminated.");% E) ]$ `8 P: b4 `7 B
      System.exit(1);" N  x- X' O3 R! M$ p8 c
      return null;
0 X- ]. E2 T  O+ r+ |. V    }
& Y$ u- |2 H$ _' `0 C" e    return sel;
& r6 v( n: U/ _# l. X* W$ o  }, K4 H* P5 N) j3 G3 k+ |

: z: q& w/ n& q  P( X  public static Selector getSelector(Object obj, String method) {
% S- F5 O% U' _7 g7 x    Selector sel;
5 ^4 a: R) {7 ~' \' Z5 \7 {    try {
; N' b% J- D1 @3 T6 v9 c% E      sel = new Selector(obj.getClass(), method, false);' S# I7 E- S( O# A; Z1 @! H% u
    } catch (Exception e) {9 z. y- W# d# d. a  ~
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "5 q9 ^# c# N' O4 b% t* W
          + (obj.getClass()).getName() + ".");5 }# C/ E5 d! g( }" r
      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
$ j/ N! x( u2 q% g& x# R* `2 N" G      System.err.println("The process will be terminated.");- `1 g. f  {1 F* v
      System.exit(1);, ~; K8 G0 I% h; G6 x
      return null;- b% g, {, h4 b, c% y. v. K" w( u
    }. C  h6 ?: Y7 \2 [' |7 m: Q* {1 y
    return sel;& Y$ }1 {: h! k: {4 I# k
  }1 v+ ^  A0 S7 e& l) B6 p
}

评分

参与人数 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-6-14 14:35 , Processed in 0.021170 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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