1
我正在嘗試創建一個代碼,將演員移動到隨機位置,如果它是開放的。但是,我遇到了這條線產生的錯誤。GridWorld實驗室問題
if (null == get(loc))
基本上我以爲這條線會檢查位置是否打開。不過,我得到這個錯誤任何人都可以幫助?
F:\Lab III Car and Teleporter\Teleporter Project\TeleporterActor.java:42: error: cannot find symbol
if (null == get(loc))
^
symbol: method get(Location)
location: class TeleporterActor
1 error
Process completed.
public void act()
{
Location place = getLocation();
Grid<Actor> gr = getGrid();
int cols = gr.getNumRows();
int rows = gr.getNumCols();
do
{
Location loc = new Location((int)(Math.random() * rows - 1), (int)(Math.random() * cols - 1));
if (null == get(loc))
moveTo(loc);
}
while (place == getLocation());
}
添加的方法定義'得到()'和'getLocation()'。 – MockerTim