I am having difficulty assigning a variable for the number of columns on the grid. I receive an error when I am instantiating the cols variable. Can anyone help me?
public void act()
{
Location place = getLocation();
Grid<Actor> gr = getGrid();
int cols = gr.getNumCols;
if (place.getCol() + 1 < cols)
moveTo(new Location(place.getRow(), place.getCol() + 1));
else
moveTo(new Location(place.getRow(), 0));
This is the error message I receive.
F:\Lab III Car and Teleporter\Car Project\Car.java:54: error: cannot find symbol
int cols = gr.getNumCols;
^
symbol: variable getNumCols
location: variable gr of type Grid<Actor>
1 error
Process completed.
You’re missing the paranthesis here.
This line shoulde should be (assuming there is actually a method
getNumCols()):