设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10526|回复: 7

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

  [复制链接]
发表于 2008-4-28 16:42:48 | 显示全部楼层 |阅读模式
这个程序我在eclipse下运行
- Z) Q' ^# }) ?8 z) B5 {5 Fsel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行% K  Z2 M' u4 c: I# [  m9 |; T9 R
5 N9 z. e7 K& @4 N& t* y7 T
似乎缺少了一个SwarmUtils的类,不知道怎么回事
$ J" V( p# `4 n! \% T' O( i3 d/ z9 B/ a0 o6 X
朋友们给个反馈??

本帖子中包含更多资源

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

x

评分

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

查看全部评分

发表于 2008-5-6 00:00:30 | 显示全部楼层
import swarm.Selector;% I& ?6 v6 S4 s& F0 H. r; P/ u( |
9 z$ u5 d+ t3 ?3 \& _# \; v
public class SwarmUtils {( b+ y* w6 Y0 Y$ {9 d
  public static Selector getSelector(String name, String method) {7 }) b9 v" m; y# M0 h1 z8 |( i3 O  G; y
    Selector sel;6 c! Y0 n  F8 G+ W0 O2 g6 X& M! ^
    try {3 ]/ h. e+ b( b
      sel = new Selector(Class.forName(name), method, false);9 Z) G+ s% k: Z7 ]) b/ X' {
    } catch (Exception e) {* R" R* j& g- P
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");2 ^" _! _* V8 K4 q' w
      System.err.println(name + "." + method + " returns " + e.getMessage());( ?6 B. h( H3 @3 I
      System.err.println("The process will be terminated.");$ t& {, ~& y, i8 Q
      System.exit(1);7 _- n: z& b0 p
      return null;
: N0 S; M3 M) t( L# D  Z    }
8 X! q; u  a0 B& z. q    return sel;! n4 \! V: B. @" d+ [$ ?
  }0 E5 w. c& f4 v4 v
3 @4 ^: S# x, O6 F* o
  public static Selector getSelector(Object obj, String method) {" C6 M+ R( k) r; h
    Selector sel;& D2 n; e% V; X
    try {
0 R! B& ]6 I, W      sel = new Selector(obj.getClass(), method, false);
2 _8 t9 f, d/ H# ~    } catch (Exception e) {
* j  b: ?) H8 t4 P8 P      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "+ u0 _: i: Y! C" Y& u
          + (obj.getClass()).getName() + ".");# s9 C8 S# @+ [5 z
      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());8 s; D1 T% ]5 H  q# z7 S
      System.err.println("The process will be terminated.");3 P1 X* k1 U0 Y' p" k3 E
      System.exit(1);& N. a& v* O( j/ j& |; e
      return null;
1 ]7 P' d! ^) J# H    }
8 A/ h0 U5 O4 I+ X5 U    return sel;
9 |. A' l( I2 \5 X- I' J5 `  }/ L6 K: n& [4 K, o1 u4 a# C
}

评分

参与人数 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-8-30 06:35 , Processed in 0.021552 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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