Complete these notes from the Code structures video
What are the 4 kinds of code structures?
Ask Questions | Repeat Code |
---|---|
|
Describe the pre and post conditions for the Cleanup program.
pre:
post:
Why is a while loop used for this program?
Why is an extra if statement needed after the while loop?
===================================================================
How can you change this program to work if there are an unknown number of balls in each stack?
Did you consider the edge cases?
// This program has karel walk down the // row and clean up all of the tennis balls // on the way. function start(){ while(frontIsClear()){ if(ballsPresent()){ takeBall(); } move(); } if(ballsPresent()){ takeBall(); } }