« CS106A: Programming Methodology Assignment 1.2 | Main | Hat Tip: Parlar.ca for code formatting instructions for SquareSpace »
Wednesday
Dec052012

CS106A: Programming Methodology Assignment 1.1


/*
 * File: CollectNewspaperKarel.java
 * --------------------------------
 * At present, the CollectNewspaperKarel subclass does nothing.
 * Your job in the assignment is to add the necessary code to
 * instruct Karel to walk to the door of its house, pick up the
 * newspaper (represented by a beeper, of course), and then return
 * to its initial position in the upper left corner of the house.
 */

import stanford.karel.*;

public class CollectNewspaperKarel extends Karel {
	
	// You fill in this part
	public void run() {
		turnRight();
		move();
		turnLeft();
		move();
		move();
		move();
		pickBeeper();
		turnAround();
		move();
		move();
		move();
	}
	
private void turnRight() {
	turnLeft ();
	turnLeft ();
	turnLeft ();
}

private void turnAround() {
	turnLeft ();
	turnLeft ();
}

}