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 assinments, 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 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

In this assignment you will how to download, compile, and run a JCreator project. You will then learn about the very basics of coding:
Introduction: Classes and ObjectsDeclaration, Instantiation, Assignment, and MessagingBlocks and SyntaxParametersAssignment: Turtle Drawing

1.2. Methods

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.
Creating a MethodMethods with ParametersInstance variablesAssignment: Artist

1.3. Creating a new Class

Suppose that I had several objects that wanted to use the square() method that I wrote for Controller to use. Instead of adding these methods to all those classes, it would make more sense just to add those methods to Turtle, so that I could get a turtle t to draw a square by typing t.square() instead of this.square(t). This has the added advantage that I don't need to pass a Turtle as a parameter to the square() method, since the turtle who's supposed to make the square is the one that got the message.

In general, I don't want to modify a class that someone else wrote to add the mehods I need; I won't always even have access to their source code. Instead, I extend their class, writing a new class that inherits all the properties of the old class, but adds new methods.
InheritanceOverriding MethodsReturn Values and VisibilityConstructorsCase Study: TurtleWithBuddy
Assignment: Alternator

1.4. Looping

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 ExpressionsLoopsLoops 2Case Study: Plotter
Assignment: Geometer

1.5. 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 StatementsRecursionLoops and RecursionCase Study: Towers of Hanoi
Assignment: FractalTurtle

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.

Project: MeshTurtle

The Turtles assignment has no associated long-term project, since it is mostly introductory. Instead, it has more assignments than a usual project.

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.
SpecificationsObject ModelsAssignment: Asteroid Buster

2.2. Decision Making

Looping is one important control structure that we learned before. Often, however, instead of repeating some block of code, I have to decide to either execute that block of code or not, based on some condition.
Condition SyntaxControlAssignment: 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

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 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 Overview