## cs106a – Lecture #7 to #9: Further Java

Prerequisites to the seventh lecture is reading chapter 5 of “Art and Science of Java”. The lecture explains how methods are defined in Java and how parameters are handled.

Prerequisites to the eight lecture is reading chapter 6 of “Art and Science of Java”. The lecture provides an overview about instance variables and objects as well as introduction to generating random numbers.

Lecture provides further details about how to create new classes, instance variables (including shadowing), and constructors closes by introducing javadoc.

Code for these lectures are available on github.

## cs106a – Assignment #1 – Task #4

As an exercise in solving algorithmic problems, program Karel to place a single beeper at the center of 1st Street. For example, if Karel starts in the world

it should end with Karel standing on a beeper in the following position:

## cs106a – Assignment #1 – Task #3

In this exercise, your job is to get Karel to create a checkerboard pattern of beepers inside an empty rectangular world, as illustrated in the following before-and-after diagram:

This problem has a nice decomposition structure along with some interesting algorithmic issues. As you think about how you will solve the problem, you should make sure that your solution works with checkerboards that are different in size from the standard 8×8 checkerboard shown in the example. Odd-sized checkerboards are tricky, and you should make sure that your program generates the following pattern in a 5×3 world:

Another special case you need to consider is that of a world which is only one column wide or one row high. The starter folder contains several sample worlds that test these special cases, and you should make sure that your program works for each of them.

## cs106a – Assignment #1 – Task #2

Karel has been hired to repair the damage done to the Quad in the 1989 earthquake. In particular, Karel is to repair a set of arches where some of the stones (represented by beepers, of course) are missing from the columns supporting the arches, as follows:

## cs106a – Assignment #1 – Task #1

Your first task is to solve a simple story-problem in Karelâ€™s world. Suppose that Karel has settled into its house, which is the square area in the center of the following diagram:

## cs106a – Lecture #3 to #6: Starting with Java

Prerequisites to the third lecture is reading the chapters 4 to 6 of “Karel the Robot learns Java”. They provide an introduction to top-down design and algorithms.

Prerequisites to the fouth lecture is reading the chapters 1 and 2 of “Art and Science of Java”. The lecture provides a brief history of computer science and describes how the lessons learned from Karel can be translated to Java.

Prerequisites to the fifth lecture is reading chapter 3 of “Art and Science of Java”. The lecture provides an introduction into variables an data types.

Prerequisites to the sixth lecture is reading chapter 4 of “Art and Science of Java”. The lecture further introduction into using variables, their scope and how to combine them, as well as constants and last but not least combining boolean structures.

Code for these lecture as well as the used worlds are available on github.

## cs106a – Lecture #2: Programming & Control Structures

Prerequisites to the second lecture is reading the chapters 1 to 3 of “Karel the Robot learns Java”.

Karel knows four basic commands (or methods):

move()
turnLeft()
pickBeeper()
putBeeper()

To run feed Karel commands, first import Karels basic commands, create a class derived from Karel and put the commands into a run() method:
Continue reading “cs106a – Lecture #2: Programming & Control Structures”