2012-03-18 26 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