| | |
Help with simple program
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Basically, I am trying to solve a problem a textbook. The book requires me to use karel J robot to develop programming principles. So the problem is correctly the following code so that the robot will do this: attached
This is the code I am suppose to fix. Currently the robot moves in a straight direction and doesn't turn. I do not know why. Please give me some hints, any help could be appreciated.
This is the code I am suppose to fix. Currently the robot moves in a straight direction and doesn't turn. I do not know why. Please give me some hints, any help could be appreciated.
java Syntax (Toggle Plain Text)
import cs1Lib.karel.Robot; import cs1Lib.karel.World; public class PlantSquare extends Object { public static void main(String[] args) { World world = new World(); Robot karel = new Robot(12); world.addRobot(karel, 1, 1, World.EAST); int side = 0; while (side < 4) { int step = 0; while (step < 3) { karel.move(); karel.putBeeper(); } karel.turnLeft(); } karel.turnOff(); } }
Last edited by cscgal; Sep 11th, 2008 at 2:04 am. Reason: Added code tags
•
•
Join Date: Oct 2006
Posts: 1
Reputation:
Solved Threads: 0
Your while loops don't have any end to them. The first one would execute the second one, and since the second loop never ends, the code never gets used. Try making the loops end so the other code can start.
Java Syntax (Toggle Plain Text)
karel.turnLeft()
![]() |
Similar Threads
- Help with Simple C program :) (C)
- Can someone help me develop a simple program (Visual Basic 4 / 5 / 6)
- can anyone help me develop a simple program (Visual Basic 4 / 5 / 6)
- Need advice & help with a very simple program (IT Professionals' Lounge)
- Simple while loop in c++ (C++)
- Erroneus outputs in string manipulation simple program (C++)
- I am a girl doing my 1st simple program (C)
Other Threads in the Java Forum
- Previous Thread: Static or not problem.
- Next Thread: hibernate mapping classes
| Thread Tools | Search this Thread |
addball android api applet application apps array arrays automation binary bluetooth businessintelligence button card chat class classes client code collision component crashcourse css csv database eclipse ee error event exception fractal free game gis givemetehcodez graphics gui html ide image input integer integration j2me java javaarraylist javadoc javafx javaprojects jni jpanel julia jvm key linux list loan loop machine map method methods migrate mobile netbeans newbie nls oracle output phone physics print problem program programming project radio recursion reporting scanner screen server service set size sms socket software sort sql string swing textfield threads time transfer tree trolltech utility windows





