设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10609|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行
0 X, s9 j8 {* |, x& T1 I* Csel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行. X  ~+ h9 \9 R8 R" Y

4 g/ [- T: A, c; o似乎缺少了一个SwarmUtils的类,不知道怎么回事 5 U+ m' ]& w4 t( _' x
( r7 v+ A. T" c
朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;
4 {/ e* m; M* W9 E
  E+ ?+ f, b" S$ Y+ D' tpublic class SwarmUtils {
2 I0 _6 `" h- S2 h7 `9 k$ c  public static Selector getSelector(String name, String method) {% u$ b( s# {8 v
    Selector sel;7 b, }) @7 C3 Q0 x" f* ?8 n, n
    try {
5 Q1 ^9 j0 S! N8 J      sel = new Selector(Class.forName(name), method, false);9 T# X( @" g1 Q3 s4 ]; ]6 a
    } catch (Exception e) {
0 \# m& A8 M8 c      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");: l: A3 S- G& Z8 T5 F3 n& E4 m* c" A
      System.err.println(name + "." + method + " returns " + e.getMessage());3 R5 x- N% q) w$ M
      System.err.println("The process will be terminated.");% T& Q$ ^' E/ z, ]/ H
      System.exit(1);; [# a5 K; R5 @( X% ~* |
      return null;
+ i/ {- z6 h' P9 y3 [" `! l    }1 S6 e5 T2 l+ T  G1 M: ^( d  k
    return sel;
2 K* f4 F& R8 j* ?& R* _! B: M  }$ c; y$ m; T4 |' b, I" g! w

& F' ~: V: [  b' m0 @% f# X  public static Selector getSelector(Object obj, String method) {
, B8 \9 N1 x8 \& Z) K    Selector sel;& e, b+ {* J7 w* ?1 n) z& j! b, q  O: u6 H
    try {! Z: k$ d! |7 V+ g$ F
      sel = new Selector(obj.getClass(), method, false);
  W0 \6 i) R% |    } catch (Exception e) {  D* |  H6 n1 w" B; [
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
4 Z% j. c9 o9 G& A          + (obj.getClass()).getName() + ".");
, R9 d# P! d, z: _: E5 v      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());+ J, ]1 x1 j' z! d: U4 I
      System.err.println("The process will be terminated.");
. M/ y4 L# k6 u# i      System.exit(1);! d: h% f* g4 v) l, g5 I
      return null;; H7 s) l. N9 e2 S7 {6 E( q
    }2 ]  v# \  V$ a( a  b1 M
    return sel;
6 [( ?/ N1 A/ g$ ~7 X2 v5 Z" v  }
  I+ ~/ k8 Z7 Y9 r$ q/ ]* a, l}

评分

参与人数 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-9-9 03:55 , Processed in 0.018318 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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