Table of Contents

During each term, you will be complete at least two projects. For each project, there is some preexisting program that you will modify in some way. So, for example, when you get Asteroids it accomplishes the remarkable feat of displaying a window on the screen and painting it black; it is your job to program the objects that will move around, respond to key presses, and interact with each other.

In addition to the specific skills targeted by each of the assingments, you are also learning the whole time about new ways to structure information and algorithms, and about how to make use of code that someone else has written. In each project, you need to figure out how to take the capabilities that I have already provided the program with, and plug in what you need to get the behavior you want. Since in real life you will always be working with several other people, being able to integrate your code with theirs is a very important skill.

The "case studies" included with some sections provide an alternate way to learn the material: by observing how those concepts are used in actual code. When trying to solve a problem in computer programming, it is often helpful, especially for a beginner, to look at how someone else solved a similar problem.

When working on programming assignments, you will always work in pairs at a single computer - one person typing, the other consulting with them. This is known as pair programming, and is the industry standard paradigm for working on the more complex parts of a programming project. The person who is not typing is able to catch any typos, rethink how the program should work, and in general help the work move along smoothly.

Mr. Z. and his brother usually start off a programming project with a several hour pair programming session, switching off who's typing often as they get to a piece that speaks more to the particular skills of one or the other. For example, Michael (the other Mr. Z.) is really good at writing code to load information from files.

Partners will be switched after each project. Mr. Z. will try to pair stronger programmers with weaker ones, so that no one in the class is left behind.

At the end of the year, after the AP exam, there will be a chance to work with any partner you like on some project of your choosing. You will also have a chance to investigate summer internship opportunities offered by Mr. Z.'s many contacts in the field.

Class will switch off between learning classes and working classes. Usually, a new concept will be introduced in a few learning classes, along with a homework worksheet or two to give you a chance to practice it. Next, you will be given a brief assignment making use of these new concepts, first by a tutorial section that tells you almost directly what you need to do, then by a few optional extensions with hints on how you might implement them.

1. Turtles

In the final project for Turtles, you will
create a class of turtle that can draw
"polygon meshes" like this.
In this project, creatures called "Turtles" move around on the screen. Each has a colored pen that it can use to draw a line as it moves. Using the basic turtle actions of moving, turning, raising and lowering the pen, and changing the pen color, you will produce increasingly complex sketches. You will then begin to design new types of turtles with new capabilities. You will become familiar with the basic structure of a Java class, and you will learn how to use loops and recursion to control repeated tasks.
Turtles Overview

1.1. The basics

Assignment: Turtle Drawing (9/19/05)
In this assignment you will how to download, compile, and run a JCreator project. You will then learn about the very basics of coding:

Classes and Objects (pdf) (Due: 9/12/05)

Declaration, Instantiation, Assignment, and Messaging (pdf) (Due: 9/14/05)

Blocks and Syntax (pdf) (Due: 9/15/05)

Parameters (pdf) (9/16/05)

Syntax Review (pdf) (Due: 9/19/05)
Assignment: Turtle Drawing (9/19/05)

1.2. Methods

A sample Artist turtle bouquet.
Assignment: Artist (9/26/05)
In the last assignment, you ended up having to write out dozens of lines of code in the run() method. To make your code easier to understand, you could separate out each of the three parts of the drawing into a method of its own. This also allows you to reuse that same pattern of instructions in another place by just calling the method.
Working with Methods (pdf) (Due: 9/20/05)

Methods with Parameters (pdf) (Due: 9/21/05)

Instance Variables and Visibility (pdf) (Due: 9/23/05)

Methods Review (pdf) (Due: 9/26/05)
Assignment: Artist (9/26/05)

1.3. Creating a new Class

The Alternator turtle class.
Assignment: Alternator (10/11/05)
In writing the Artist class, we created a new type of Turtle, one that knows how to do everything a Turtle can do, but also has some special new methods of its own. We say that Artist is a subclass of Turtle, a special new type of Turtle that inherits all the capabilities of a Turtle, but also extends Turtle by adding new capabilities.

In this assignment, we will study in more detail what goes into a new Java class. By the time you are done with this assignment, you will know almost everthing there is to know about creating a new Java class.
Inheritance (pdf) (Due: 9/28/05)

Constructors (pdf) (10/6/05)

Overriding Methods (pdf) (10/7/05)

Classes Review (pdf) (Extra credit, 10/11/05)
Case Study: TurtleWithBuddy
Assignment: Alternator (10/11/05)

1.4. Looping

Assignment: Geometer (40 pts, 10/26/05)
In the methods you've written for the previous sections, you often had to repeat the same lines of code over and over. One way to simplify this is to package the repeated code into a method, and call that method many times. But this is still not ideal if I want to repeat something many times.

Now we will learn the built in mechanisms that Java has for repeating a block of code and controlling how many times it repeats. This is your first experience of working with program control statements.
Math Expressions (Due: 10/18/05)
Loops (Due: 10/19/05)
Loops 2 (Due: 10/20/05)
Case Study: Plotter
Assignment: Geometer (40 pts, 10/26/05)

1.5. Recursion

Fractals are just one of the more
beautiful applications of recursion.
Often looping is not the most natural solution to a problem. Instead, it makes more sense to break up a large problem into several smaller problems, and break up each of those into even smaller problems, until we finally encounter a problem that we know how to solve.
If Statements (pdf) (Due: 10/27/05)
Recursion (pdf) (Due: 10/31/05)
Loops and Recursion (pdf) (Due: 11/9/05)
Case Study: Towers of Hanoi
Assignment: FractalTurtle (40 pts, 11/9/05)

1.6. The Project

In the project for Turtles, you will put together all the things you have learned so far to write a new class of turtle that uses both recursion and looping to draw a "mesh," a set of polygons connected by their edges. Some of the extensions for this project involve writing Turtle subclasses to explore other aspects of fractals and geometry, such as Brownian motion.
Turtles Review (11/4/05)

Project: MeshTurtle (80 pts, 11/23/05)

2. Asteroids

In this project, you will design a simple "asteroids" game in which the player controls a ship that moves back and forth at the bottom of the screen, and attempts to avoid asteroids that fall from the top of the screen, either by destroying them with lasers or by steering around them. In the process, you will become very comfortable with designing and implementing an object subclass, including writing constructors and overriding methods. You will also learn how to use if statements and complicated conditions.
Asteroids Overview

2.1. Project Architecture

When starting out working on a project that has already been written, you need to take some time to understand the "architecture" of the project: what classes it has, what the responsibility of each class is, and how the classes relate to each other.
Object Models (pdf) (Due: 1/6/06)
Assignment: AsteroidBuster

2.2. Decision Making

We leaned a little bit about if statements when we studied recursion in the Turtles project. We learned that if statements are used to execute a different block of code depending on some condition. Now we will learn how to use more complicated conditions and more complex types of program control structures.
Condition Syntax
For Loops (pdf) (Due: 11/17/05)
Assignment: Healthy Asteroids

2.3. The Project

Now it's time to put together all that we've been learning so far this term and see if you can write a really quite complicated program. Unlike the assignments that you have done so far, the Asteroids project will require you to write several classes that interact with each other.

This added level of complexity makes it harder to figure out how the program goes together, since there isn't jsut one object controlling everything. However, it also allows you program to have much more complex behavior than what you've seen before. When you are done with it, Asteroids will be a game good enough that you will be proud to post it on the website for your friends to play, and each team will have a somewhat different variant of it.
Project: Asteroids (30 pts, 12/23/05)

3. Vectorized

This next game adds two levels of complexity. Unlike Asteroids, it has preprogrammed levels created in an editor, so that puzzles, strategy, and plot may start to emerge. It also has, in addition to objects that move around and interact, an environment that they interact in.

As a result of this, information in Vectorized needs to be more rigidly structured; it is not enough to have just a list of all the obejcts in the game and let them all interact with each other. In this project, you will learn about linked lists, a popular way to organize information in a computer, and you will learn about stacks, lists, queues and priority queues, which are ways of organizing a list of events that need to happen in order.
Vectorized Overview

4. Calculator

In this project, you will learn about the programming data structure called a "tree." You will do this be writing a fully functional calculator in which you can type a mathematical expression and get the result, similar to what you can do on Google or a TI graphing calculator's home screen.
Calculator Overview

5. Strategic

Many of you probably enjoy playing games like Starcraft in which you take the role of the leader of a town or civilization and have to collect resources and fight opponents. In order to write this game, you will learn about arrays, which are the computer's way to store a rectangular grid of objects, like the tiles in a map. You will also learn about interfaces, which define a set of methods that one object needs another to implement in order to be able to work with it.
Strategic Overview

6. Assorted

It's a problem you've dealt with often in PE class: a group of people in a line have to arrange themselves by height. Usually, there's some amount of milling around, but eventually people find themselves in the right spot.

But what if, rather than everyone sorting themselves, you have to walk back and forth along the line and rearrange things yourself? If all that you were allowed to do is to ask people to compare themselves to another person, swap places with someone within their line, or insert themselves into a new line, what would be the most efficient way of doing it? How would the number of comparisons, swaps, and insertions grow if you made the line much longer?

In this project, you will learn about the strengths and weaknesses of several sorting strategies. You will also learn how to describe how the complexity of an "algorithm" (a stretegy for solving a problem) grows when the nuber of objects involved grows.

Assorted is an optional project that you can do if you want to take the AP Computer science AB test instead of AP Computer Science A. The AB test is a little bit more difficult and a little bit more prestigious.

(To be honest, neither test will get you out of a first-year college programming class. Colleges like to train their CS majors from the start, to make sure they learn everything the "right" way. But doing well on either test will help you in your college applications.)
Assorted Overview