我正在尝试创建一个代码,如果它是打开的,它将把一个演员移动到一个随机位置。但是,我在处理此行导致的错误时遇到了困难。
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());
}