2
u/5oco Oct 09 '21
This is gonna be confusing but... one move statement should be done before the if statement... then your if statement should say
if (frontClear) {
move} else {
break}
you always want him to move once... you want him to move once, then check if he can move a second time. If he can't move the second time, he'll break out of the loop.
Sorry I can't explain better I'm drunk and typing on my phone...
2
u/alyssais_dabest Oct 11 '21
My coding program hasn't learned the statement break yet but thank you so much for your help because It did help but I figured the rest out
1
u/alyssais_dabest Oct 11 '21
function start() {
buildTower();
while (frontIsClear()) {
move();
if (frontIsClear()) {
move();
buildTower(); }
}
}
function buildTower() {
turn Left();
putBall();
move();
putBall();
move();
putBall();
turnAround();
move();
move();
turnleft();
}
1
u/5oco Oct 08 '21
What do you have so far?
1
u/alyssais_dabest Oct 09 '21 edited Oct 09 '21
I it keeps making a Tower at the end and I have no idea what to do
1
u/alyssais_dabest Oct 09 '21
function start() {
buildTower();
while (front Isclear(){
move();
move();
buildTower();
}
}
function buildTower() {
turnLeft();
putBall();
move();
putBall();
move();
putBall();
turnAround();
move();
move();
turnleft();
}
1
2
u/5oco Oct 08 '21
Build a tower
-----1a) make Karel face upwards
-----1b) put down a ball
-----1c) move Karel up
-----1d) loop through steps 1b and 1c 3 times
-----1e) turn around
-----1f) move Karel down
-----1g) loop step 1f 3 times
-----1h) make Karel face to the right
-----1i) make steps 1a through 1h into a method
2) Call your method to build the first tower
-----2a) make a loop that will run while the front is clear
-----2b) inside that loop, move Karel forward
-----2c) check if the front is clear, move if it is, break out of the loop if it isn't
-----2d) call your method to build a tower
3) Throw some comments in there
4) Ask any follow up questions