设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9850|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行( E1 O. A: s9 V. A5 k  }& J
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行) p) w5 v3 C( m$ S, f4 R5 b5 L
  h1 ^" z/ v" }: |3 J
似乎缺少了一个SwarmUtils的类,不知道怎么回事 3 ~: n6 c1 _+ l3 M

: H5 k2 Y5 w" s朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;
7 A* _( `2 m) N! b8 r5 H+ o1 L
. b& w9 h; ?3 i2 L" Y/ ^7 N, r4 W" dpublic class SwarmUtils {4 F9 U- m2 `& }1 P' R5 Z% F
  public static Selector getSelector(String name, String method) {
: C' F) h8 m0 g( q  P* a. s* {: O    Selector sel;& k6 P6 z7 i+ \
    try {
" L2 a) d: o; F5 s, e1 _% X      sel = new Selector(Class.forName(name), method, false);5 I7 s; F  |1 h& B7 Y7 T% x: G
    } catch (Exception e) {" R& V; Z! i- v, p% l9 I. h
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");. }3 F2 W1 Y! b+ z6 y/ {5 v
      System.err.println(name + "." + method + " returns " + e.getMessage());8 n* Q: o/ P- j
      System.err.println("The process will be terminated.");
( ^3 ]! s, ^7 \/ R: Y      System.exit(1);
$ x* U8 i! |% T  ?0 E      return null;9 P. Y# j3 Z, C; ?& @8 R
    }
: u9 r, B1 t5 x4 T    return sel;
- h- N1 F( f) ?0 d  }
7 o( W5 \* K' [1 D9 `$ I# v; C9 ^& t& I6 S
  public static Selector getSelector(Object obj, String method) {0 H+ x5 i/ J3 j3 b, M7 |2 `) r3 Q
    Selector sel;0 r( x1 `- R: Q! P
    try {8 s/ }* }! V& i/ C! C2 N  T
      sel = new Selector(obj.getClass(), method, false);
0 T, J+ U/ \! R% y+ `; _$ a. B    } catch (Exception e) {
) `* t. Z) @1 ?6 r2 A. r5 C& E9 r      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "! y- X$ W9 A6 A" l( t
          + (obj.getClass()).getName() + ".");
- T. M4 Y6 `( F* ?3 C      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());* c1 P) t1 c2 X9 u' {
      System.err.println("The process will be terminated.");
7 R, w  ]6 u2 M$ u9 H      System.exit(1);
' \& K) m) h2 b      return null;9 R% r2 U1 ^* b9 @- Q- q' J8 |
    }
; \  ^& N9 B8 V: }    return sel;6 D  H' N: }9 e) @$ A
  }
$ W5 V/ K5 \" k# t}

评分

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

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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