2012-03-18 72 views
-1

我试着做任何连接到IRC一个Java机器人,然后当用户键入命令时,“滚动骰子”,但它似乎没有工作Java的IRC骰子机器人不工作

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

+0

您有编译器错误。 – Jeffrey 2012-03-18 00:56:14

+0

尝试通过cmd使用javac编译,仍然得到这些错误 – Epicblood 2012-03-18 01:06:58

+0

是的,你的代码中有编译错误。无论您使用哪种编译器,都会得到这些错误。 – Jeffrey 2012-03-18 01:09:54

回答

1

问题与roll

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

问题与Dice4Cash

  • 您不能访问一个不存在的字段。您既不创建IntRoll字段也不创建OpRoll字段。

我强烈建议你通过一些Java教程,学习语言。
Getting Started
Learning the Java Language