QUESTION IMAGE
Question
question 24
in the following code, what would be a good post - condition to write?
/* precondition: karel is on a spot with a tennis ball facing east
postcondition: ...
*/
function getontop() {
turnleft();
move();
turnright();
}
karel is on a spot with a tennis ball facing north
karel ends one spot above a tennis ball facing east
karel is on the same position but on top of a ball
karel is facing east
The function getOnTop first turns left (from facing east to north), then moves forward one spot, and then turns right (back to facing east). So Karel ends one spot above the original position (where the tennis - ball was) and is still facing east.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
Karel ends one spot above a tennis ball facing East