-1

我试图制作一个连接到 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

4

1 回答 1

1

问题roll

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

问题Dice4Cash

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

我强烈建议您阅读一些 Java 教程并学习该语言。
入门
学习 Java 语言

于 2012-03-18T01:18:21.940 回答