java irc Dice bot无法正常工作

时间:2012-03-18 00:47:44

标签: java irc bots dice

我试图创建一个连接到IRC的java机器人,然后当用户键入命令时,它“滚动骰子”但它似乎无法正常工作

cannot find symbol variable IntRoll
illegal start of type
cannot find symbol variable OpRoll
illegal start of type
cannot find symbol variable Op
cannot find symbol variable IntRoll
illegal start of type
cannot find symbol variable OpRoll
illegal start of type
cannot find symbol variable Op
cannot find symbol variable Op
cannot find symbol variable generator
int cannot be dereferenced
cannot return a value from method whose result type is void
int cannot be dereferenced
cannot return a value from method whose result type is void
cannot return a value from method whose result type is void
cannot return a value from method whose result type is void
cannot find symbol variable generator
cannot find symbol variable InRoll
cannot return a value from method whose result type is void
cannot find symbol variable InRoll
cannot return a value from method whose result type is void
cannot return a value from method whose result type is void

这是两个文件,    http://pastebin.com/c47RqRsd    http://pastebin.com/v4Y42uF4

1 个答案:

答案 0 :(得分:1)

roll的问题:

  • 您无法从构造函数返回值。构造函数用于实例化对象。您应该创建一个字段并将其设置为InRoll
  • 如果您尝试用骰子生成2到12之间的数字,那就不是这样做的了。你会得到一个不切实际的分布,你可以获得比正常情况更多的分数。
  • 您无法在基本类型上调用方法。您应该使用InRoll == someNumber
  • 如果返回类型为void,则无法在方法中返回值。
  • 您没有创建名为InRoll的字段,因此您无法在onMessage方法中使用它。

Dice4Cash的问题:

  • 您无法访问不存在的字段。您既不会创建IntRoll字段,也不会创建OpRoll字段。

我强烈建议您逐步学习一些Java教程并学习语言 Getting Started
Learning the Java Language