07-Karel-Banishes-Winter

07-Karel-Banishes-Winter - CS106A Handout 07 April 4th,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS106A Handout 07 Spring 2011 April 4 th , 2011 Karel Banishes Winter Code by Eric Roberts. Karel’s first large assignment is to walk across campus and spruce it up a bit for Admit Weekend. Spring has sprung, but the campus trees haven’t gotten the memo and are still leafless. Karel needs to walk from Campus Drive West to Campus Drive East, adorning all trees with artificial leaves and transforming the campus from this: to this: The problem is complicated before Karel doesn’t know how tall each tree is, nor does she know the distances between them. She does know, that she has just enough beepers in her beeper bag starting out to decorate all of the trees. You can likely intuit the program requirement by looking at the two snapshots above.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 public class BanishWinter extends SuperKarel { /* Main program */ public void run() { while (beepersInBag()) { findTree(); addLeavesToTree(); } moveToWall(); } /* * Moves Karel up to the next tree. * * Programming style note: Since a tree is simply a wall,
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/28/2011 for the course CS 106A taught by Professor Sahami,m during the Spring '08 term at Stanford.

Page1 / 3

07-Karel-Banishes-Winter - CS106A Handout 07 April 4th,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online