设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8970|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行$ C' Q3 [+ C. V, h
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
  }  w8 ?* C: b0 B! A: \2 I7 w+ i1 R) G. P
似乎缺少了一个SwarmUtils的类,不知道怎么回事 ) S  K, g( [. f  B6 b/ w  ^+ G

$ _8 F& K6 t. S4 x( Z% ~9 ]朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;
7 Q# V4 z* i+ T3 V( w1 w2 n
$ u. u$ n" a$ f- ]& Rpublic class SwarmUtils {
6 @  G4 j7 F3 d, k4 H+ d  public static Selector getSelector(String name, String method) {
/ \7 X6 P* p* y. K; }' ]    Selector sel;+ G8 K$ `! g+ C6 @
    try {# \8 k8 ]/ c0 O( A9 F7 |- j8 q  t
      sel = new Selector(Class.forName(name), method, false);) i. h! x/ ?7 B; I* Z
    } catch (Exception e) {
  j" J$ W# Y; H* I9 O* m      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
# K( V+ y5 O3 b7 x      System.err.println(name + "." + method + " returns " + e.getMessage());! q8 U2 r1 H$ f/ P; Q% o3 t# f
      System.err.println("The process will be terminated.");
, q% x, H% B9 R$ O& q      System.exit(1);
% ]; a# t: l$ j- a/ J      return null;
0 y5 M5 N) L' j4 a% T4 B* q    }
( J9 t* U9 `$ U4 N3 Y9 E& ~. a    return sel;
% s7 N. {7 }: }1 N% L1 z$ `4 r  }% K* @2 ?) w' q' @/ S6 d$ i: o
+ _5 ?8 y4 q# [, z! x
  public static Selector getSelector(Object obj, String method) {0 ]; r5 L. R" l% f- B" i7 {
    Selector sel;6 |% H/ K$ }) f5 O
    try {
* I, [* T: B  `0 R) `      sel = new Selector(obj.getClass(), method, false);- s, \  q5 E. j6 J- ~; A3 [
    } catch (Exception e) {
6 X  p0 {! g& @/ n! b3 a) E      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
% \3 M  t% a9 E4 v# }' g+ X  h          + (obj.getClass()).getName() + ".");$ N6 K* ]3 r4 \0 ^
      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
2 G' Z' ]; B1 a4 Z3 [+ X0 K      System.err.println("The process will be terminated.");
# J5 K2 `. ]6 x! D# Q, V      System.exit(1);
1 f$ {- g* h$ D% I: x      return null;
2 a! y* Y3 J% f- v7 X    }
5 F# a$ j, D# B    return sel;
2 R$ R7 r/ H, p# B9 m" P* @( l: a  }0 n( Z6 O' x4 Q5 J) X$ r) U  ?
}

评分

参与人数 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-2-19 13:23 , Processed in 0.018023 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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