im trying to make a snake game part of my class project. but mi completely new to programming so im already stuck at the beginning. the following code inst compiling. it says at line 31
cannot find symbol - variable length
ive used .length before when i was going through the book and it worked fine but its not working here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.List; import java.awt.Color; /** * Write a description of class SnakeWorld here. * * @author (your name) * @version (a version number or a date) */ public class SnakeWorld extends World { /** * Constructor for objects of class SnakeWorld. * */ public SnakeWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 600 , 400 , 1 ); createAnts(); } /** checks to see if there are any ants in the world * if there arent then it adds one ant */ public void createAnts() { if (getObjects(Ant. class ).length == 0 ) { addObject( new Ant(), Greenfoot.getRandomNumber( 550 ), Greenfoot.getRandomNumber( 350 ) ); } } } |