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.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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

cs106 – assignment #1 – task #4 – start

it should end with Karel standing on a beeper in the following position:
cs106 – assignment #1 – task #4 – end

Continue reading “cs106a – Assignment #1 – Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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:

cs106 – assignment #1 – task #3 – 8×8

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:
cs106 – assignment #1 – task #3 – 5×3

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.

Continue reading “cs106a – Assignment #1 – Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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:

cs106 – assignment #1 – task #2 – start

Continue reading “cs106a – Assignment #1 – Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail