设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9549|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行- Y: P  o. v  t* Z) b
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行" f+ G' f6 F8 j: @1 K
* ?* e* y8 D7 S- S  y+ p) y
似乎缺少了一个SwarmUtils的类,不知道怎么回事 - C/ r9 q9 ]; l* A2 ]+ V4 t/ j
' m- D; C4 |9 `7 A. G
朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;
# a. M& X+ I8 x) V6 o3 Q7 r
* _( i' @2 S. d$ d* f; mpublic class SwarmUtils {
# |/ p* T$ @1 i' `. ]# i" m. x* W6 c  public static Selector getSelector(String name, String method) {; |* \' f6 d$ y
    Selector sel;
. I6 L# C2 G* a    try {! ~  w  f- q' k  [" a
      sel = new Selector(Class.forName(name), method, false);
% N" ^' d9 y: `    } catch (Exception e) {
. I8 Y, }. T" [      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
* C9 Y  `8 }* {3 b! s1 N% k1 }! t      System.err.println(name + "." + method + " returns " + e.getMessage());
6 w( p( k# u5 E, Z$ }( ]      System.err.println("The process will be terminated.");
9 ^& D6 F6 o( @8 T9 v5 g& Y      System.exit(1);- J6 Q0 D- ]2 N3 c: z5 ~# R5 \; K
      return null;
' _: j- Y2 r2 S, k! H! d    }
+ v5 {& ~* _: e7 L    return sel;+ Z6 l! m% l. c# s# v
  }
$ |' \- X. o& R. O( [- V; b6 ~8 T. Z
  public static Selector getSelector(Object obj, String method) {
( o1 @8 s: @. S8 Z3 R* ?( d4 _* D7 v( G    Selector sel;
( j" X, c9 S" T; d9 k    try {
7 @" _+ z+ X1 I$ p" X+ l/ W      sel = new Selector(obj.getClass(), method, false);
4 W& H& y4 r/ w' H    } catch (Exception e) {
+ K* q# |7 {+ \5 i      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "0 ~1 f( ^  C! X
          + (obj.getClass()).getName() + ".");( |  @$ p7 F7 ]
      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 o( d: n2 [+ V' F% u
      System.err.println("The process will be terminated.");
# h5 @8 H" I* o8 }. V( }. z# Q8 A; s      System.exit(1);! D- D3 b/ \) _" A- j
      return null;
  ^7 \8 o  U& L! G' z  h6 U5 V    }
8 k/ P) Y1 S, A% X, {$ k    return sel;
) c8 W, _, H/ @- J  t$ }  }
! O! D- `' Z- v2 O: N6 w1 R* V}

评分

参与人数 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-5-7 05:31 , Processed in 0.024982 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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