Results 1 to 3 of 3
Thread: What is wrong with my code????
- 12-31-2010, 03:39 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 1
- Rep Power
- 0
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();}} }
- 12-31-2010, 04:16 PM #2
Senior Member
- Join Date
- Nov 2010
- Posts
- 210
- Rep Power
- 3
Without you being more specific about what it is that you expect the program to do, this is the best I can offer:
won't compile. You probably meant to doJava 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==true)
Additionally, you declared the variable as robotIzZero, so the compiler won't recognise robotsIsZero at all.Java Code:while(robotsIsZero)
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 04:20 PM.
- 12-31-2010, 06:06 PM #3
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
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
-
What Could be Wrong with This code????
By Manfizy in forum New To JavaReplies: 9Last Post: 08-22-2010, 11:28 AM -
what is wrong in dis code?
By jitun2004 in forum New To JavaReplies: 8Last Post: 04-15-2009, 09:30 AM -
what's wrong with my code? please help me...
By lovely23 in forum Java AppletsReplies: 2Last Post: 03-01-2009, 01:33 PM -
what's wrong with this code?
By agenteleven in forum Advanced JavaReplies: 5Last Post: 10-07-2008, 11:26 AM -
what is wrong with this code
By masaka in forum New To JavaReplies: 5Last Post: 04-16-2008, 08:27 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks