Computer Science Canada

'.class' expected compiler error

Author:  Justin_ [ Wed Mar 29, 2006 3:38 pm ]
Post subject:  '.class' expected compiler error

with the for loop it does not compile, without it it does.
Java:

public class Threads1
{
    public static void main(String[] args)
    {
               
        City city = new City();
                SmarterRobot karel = new SmarterRobot(city, 2, 0, Directions.EAST, 4);
                CityFrame frame = new CityFrame(city);
       
                Walls.makeWall(1, 4, 3, city , "WEST");
        Walls.makeWall(1, 4, 3, city , "NORTH");
       
        for(int fourTimes = 0; int fourTimes < 4; fourTimes++)
        {
          karel.putThing();
          karel.move(3);
          karel.turnRight();
        }
       
       
    }
}

Author:  HellblazerX [ Wed Mar 29, 2006 4:10 pm ]
Post subject:  Re: '.class' expected compiler error

Java:

        for(int fourTimes = 0; int fourTimes < 4; fourTimes++)


you're redeclaring fourTimes. Just remove the int infront of the second fourTimes and it should work.

Author:  Justin_ [ Wed Mar 29, 2006 4:43 pm ]
Post subject: 

oh jees, oops.

Author:  wtd [ Wed Mar 29, 2006 5:23 pm ]
Post subject: 

code:
karel.putThing();
karel.move(3);
karel.turnRight();


This really looks like something that might be a good candidate for refactoring out into a method in a suclass of the SmarterRobot class.

Author:  rizzix [ Wed Mar 29, 2006 5:37 pm ]
Post subject: 

eclipse eclipse! (not for newbies though)


: