设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10134|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行
# x& d1 B' ]& g2 C! dsel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行
# S) s- C8 ^- z1 w- w+ G' O9 e% h2 O3 D) U6 D+ O
似乎缺少了一个SwarmUtils的类,不知道怎么回事 5 I) H) U' |* S& V4 G1 K: f: [  a1 S

: l. a: X/ `# F% k; I朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;
  e3 T  z6 G$ a( R$ s, L4 U* L' q& {6 _2 ?- y  q7 Y
public class SwarmUtils {: b1 K$ j) t& f+ C; L
  public static Selector getSelector(String name, String method) {
+ M+ e0 A; R# U3 C. n    Selector sel;
9 |4 C9 E$ I1 J3 S) Q8 j    try {# p6 R1 j$ Q" L3 q$ |- @. l0 s
      sel = new Selector(Class.forName(name), method, false);* P: I( T. ^; z* f; L
    } catch (Exception e) {
( H: \" n! w* s9 I      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");# h( b2 A$ Q" f. ]- o: \1 E
      System.err.println(name + "." + method + " returns " + e.getMessage());
8 Q3 h8 u) F4 e) t/ ?1 d* `$ u6 r      System.err.println("The process will be terminated.");. ]( d! c( Z' R: b# m
      System.exit(1);
/ e- V% L) t; I+ Q6 _, q      return null;4 G) ]( x0 n( D3 k7 z
    }
/ F9 \3 R6 c5 @9 ]" v8 Y    return sel;& f0 H. w/ C9 B5 |, S# \" b) J: o2 W
  }
% A: [! Q9 T  N! }; U6 v/ V
" K. I1 p3 G* l2 V  public static Selector getSelector(Object obj, String method) {
, t% h. E3 Y. h$ b    Selector sel;
7 s  x, W- F/ r6 u    try {
: z1 f5 |7 z5 y- J$ }" C7 o4 p      sel = new Selector(obj.getClass(), method, false);
2 `2 h6 i, Z' q) v/ l    } catch (Exception e) {" S; D  {/ D7 `; R# Q- V! `0 c# z
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "7 i0 V% A2 P- c
          + (obj.getClass()).getName() + ".");
2 z  B# a# c, B. S2 M      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 c7 a2 I2 q) D  K  g# L8 E. Z5 H
      System.err.println("The process will be terminated.");
- w$ y" N& `0 j6 c7 |( L      System.exit(1);7 L3 a9 \6 }& s* d" M" C3 I
      return null;
- d% P6 A8 c' U3 L& g4 p/ I: R5 V    }/ m* C* n! h7 [' ^
    return sel;
/ m9 I" i; [% d( E! a% d  }6 d- v* O) ]9 D  ~3 Q1 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-7-18 18:45 , Processed in 0.013280 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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