Results 1 to 3 of 3
  1. #1
    maneatingbaby is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default What is wrong with my code????

    Java Code:
    public static void missingWall()
      {
        int robots_place=1;
        while(robots_place>0)
        if(Robot.onDark()==false)
        {turnAround();
            if(Robot.frontIsClear()==false)
            {
            Robot.turnLeft();
               Robot.move();
               Robot.move();
               Lab3.turnRight();
               Robot.move();
               robots_place--;
               }
              
            else
             {Robot.move();
              robots_place--; 
         Robot.makeDark();    
             }
        }
        boolean robotIzZero=true;
        turnRight();
        while(robotsIsZero=true)
          if(Robot.frontIsClear()==true)
        {if(Robot.onDark==false);
          {Robot.makeDark();}
          else{Robot.move();}}
      }

  2. #2
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    5

    Default

    Without you being more specific about what it is that you expect the program to do, this is the best I can offer:

    Java Code:
    while(robotsIsZero=true)
    won't compile. You probably meant to do
    Java Code:
    while(robotsIsZero==true)
    but, better still, you can omit the equality test entirely, since a boolean variable can control a conditional statement on its own:
    Java Code:
    while(robotsIsZero)
    Additionally, you declared the variable as robotIzZero, so the compiler won't recognise robotsIsZero at all.

    Also, there's no code to set robotsIsZero to false, so the above will result in an infinite loop.
    Last edited by Iron Lion; 12-31-2010 at 05:20 PM.

  3. #3
    Hibernate's Avatar
    Hibernate is offline Senior Member
    Join Date
    Dec 2010
    Location
    Stockholm, Sweden
    Posts
    222
    Blog Entries
    9
    Rep Power
    4

    Default

    Quote Originally Posted by Iron Lion View Post
    Java Code:
    while(robotsIsZero=true)
    won't compile.
    Yes it will compile unless he have set his environment not to compile.
    You should set your environment the handle 'if (boolean0 = boolean1)' as an error. If you do not set your configure your environment to do this, do never type 'if (a == true)', instead just, write 'if (a)'.
    Ex animo! Hibernate
    Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.

Similar Threads

  1. What Could be Wrong with This code????
    By Manfizy in forum New To Java
    Replies: 9
    Last Post: 08-22-2010, 12:28 PM
  2. what is wrong in dis code?
    By jitun2004 in forum New To Java
    Replies: 8
    Last Post: 04-15-2009, 10:30 AM
  3. what's wrong with my code? please help me...
    By lovely23 in forum Java Applets
    Replies: 2
    Last Post: 03-01-2009, 02:33 PM
  4. what's wrong with this code?
    By agenteleven in forum Advanced Java
    Replies: 5
    Last Post: 10-07-2008, 12:26 PM
  5. what is wrong with this code
    By masaka in forum New To Java
    Replies: 5
    Last Post: 04-16-2008, 09:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •