In the following code, what would be a good Postcondition to write?
/* Precondition: Karel is on a spot with a tennis ball facing East
* Postcondition: ...
*/
function getOnTop() {
turnLeft();
move();
turnRight();
}
JavaScript
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.
Karel is on a spot with a tennis ball facing North
are you sure
No, I apologize for the confusion.
A more accurate postcondition for the given code would be:
Karel ends one spot above a tennis ball, facing East.