haircool 发表于 2008-4-28 16:42:48

科学网于同奎先生的源程序

这个程序我在eclipse下运行
sel=SwarmUtils.getSelector(market,"calculate");类似的语句不能运行

似乎缺少了一个SwarmUtils的类,不知道怎么回事

朋友们给个反馈??

base 发表于 2008-5-6 00:00:30

import swarm.Selector;

public class SwarmUtils {
public static Selector getSelector(String name, String method) {
    Selector sel;
    try {
      sel = new Selector(Class.forName(name), method, false);
    } catch (Exception e) {
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class " + name + ".");
      System.err.println(name + "." + method + " returns " + e.getMessage());
      System.err.println("The process will be terminated.");
      System.exit(1);
      return null;
    }
    return sel;
}

public static Selector getSelector(Object obj, String method) {
    Selector sel;
    try {
      sel = new Selector(obj.getClass(), method, false);
    } catch (Exception e) {
      System.err.println("There was an error in creating a Selector for method " + method + "\nin Class "
          + (obj.getClass()).getName() + ".");
      System.err.println((obj.getClass()).getName() + "." + method + " returns " + e.getMessage());
      System.err.println("The process will be terminated.");
      System.exit(1);
      return null;
    }
    return sel;
}
}

libao 发表于 2008-11-20 19:49:58

very good.

warden 发表于 2008-11-28 11:12:43

这个……在SimpleBug的代码中自带了一个SwarmUtils的类……答案如2楼所示……

guyongfa 发表于 2009-3-12 14:52:51

谢谢

学习学习

lcjfshh 发表于 2009-12-2 20:20:58

请问一下代码是添加在哪里的啊?

Jxxylj 发表于 2012-5-22 10:31:21

是单独建立一个新的JAVA文件,文件名为SwarmUtils.java,然后把上述代码复制进去就可以了:)

那个谁 发表于 2013-1-25 12:27:29

学习。
页: [1]
查看完整版本: 科学网于同奎先生的源程序