Course Overview

Table of Contents

1. Description of Course

In AP Computer Science, you will learn how to write computer software. More specifically, you will learn a language called Java that can be used to describe to the computer how to accomplish some task. You will learn this by designing and writing parts of professional quality computer games. Like doing proofs in a geometry class, there is no fixed procedure that you can memorize to solve the problems in this class; you have to be able to learn basic principles and then recognize how and where to apply them. This is one of the most difficult classes in the school - take it only if you are competent in math and you are prepared to face frustration and keep working hard.

1.1. Is this a class I would like?

Some people just find computer programming intensely frustrating; others will spend hours doing it for fun. I don't want you to be stuck in this class only to discover that you just don't enjoy it at all. I can't tell you for sure whether computer programming is something you'll be good at, but here are some things that might be good indicators:Please think carefully about whether you are ready to take on a college-level computer science course. I know that writing games sounds exciting, but sitting in the class day after day not understanding what's going on while everyone else is writing games is not too fun.

1.2. What is Java?

Java is a programming language, a way of describing a problem solving process to a computer. In some ways, this class very similar to a foreign language class. All your assignemnts will be about learning to translate your thoughts into and out of Java. Because Java is a computer language, not a human language, you have to be very precise about how you use it.

You would probably like to see a bit of the Java "code" that you'll be using all year. The most simple thing that you can do in Java is to give the computer an instruction to do something. For example, if I write this in a Java program, it tells the computer to display the message "Hello." on the screen:

System.out.print("Hello.");

At a slightly more complicated level, Java allows you to remember values by assigning them to named "variables", and then recall that value later in the program by using the variable. In the code below, I create variables called first and last to hold my fisrt and last name, and then recall these values to print out "Zahniser, Russell" in the last line:

String first = "Russell";
String last = "Zahniser";
System.out.print(last + ", " + first);

Later on, you learn how to create your own instructions, called "methods", that put together the information given to them and do something with it. So, for example, the code below defines for the computer how to print out a name. I could use this method by typing printName("Russell", "Zahniser") and it would output "Zahniser, Russell".

public void printName(String first, String last) {
   System.out.print(last + ", " + first);
}

I don't expect that you all will be able to understand what the code above means yet; that is what the class will teach you. But you should be able to recognize some of the way it works, just as you can catch glimpses of meaning in French, even if you've never studied it, just by comparison to English and Latin.

1.3. Why should I learn to program?

You can probably think of some reasons for yourself - that computer programming is a well paying job, or that practically any job in math or science requires computer programming. But these are not the really good reasons.

The primary reason to learn computer programming is that it is fun.

Computer programming is a creative endeavor: you have an idea in your mind about how you want the program to work, and you sculpt out of basic computer language an expression of your idea that other people can use and enjoy. This is why this class focuses on writing games - I want you to be able to experience, even when you are just learning, the fun of being able to make your imagination into reality.

Computer programming will also help you to learn to think better. There were two activities from high school that have given the most benefit to me later in life. Karate taught me physical discipline, and through that, the confidence that I have complete control of his body and can trust it to act as he intended - not a foregone conclusion when you're a nerdy adolescent! Computer programming acted as a discipline for my mind, teaching me to understand how my thought processes really worked, and makign me confident, when I was doing math for example, that I could come to the riht answer and know it was right.

Computer programming will also help you to communicate more clearly. Computers are very picky about how you say things, and they don't know how to guess at what you really meant when you say something unclear. I think that a lot of the skill I have in writing came to me obliquely as a side effect of programming; it made me good at following through the argument of an essay and verifying that it really did prove what I was trying to prove.

1.4. Assignments and Grading

The course is divided up into five major projects, each of which asks you to familiarize yourself with a different sort of program: a drawing program, a space shooter, a first person 3D game, a role playing game, and a biology simulation. Each project has a final project phase in which you are allowed to work with a randomly assigned partner. Leading up to that project, teaching you the skills you will need to complete it, are several individual programming assignments.

In all the assingments, you are graded based on whether you accomplish certain goals. You will always know, then, when you upload your assignment, exactly what grade you will get on it, since you can test for yourself to find out which goals you meet. This means that if you keep up with all the homework and assignments, and you are willing to put in enough work, you can theoretically get whatever grade you want. In practice, however, you may find that some of the goals go too far beyond your geometry skill or your ability to think through problems.

Homework is also an essential component of this course. Homework is collected and graded every day on a scale from 3 to 5 points. When you are absent, you are expected to print out the homework at home and have it ready to turn in the next time I see you in class. Late homework earns at most 2 points. If you tend to be absent more than about once a term, you will probably struggle in this class.

Everything that you do in every class, you will need to know fro the rest of the year. So from teh very start of the year, you need to make a commitment to be in class, taking notes, every day, and to work on each homework assignment until you are sure that you get it.

1.5. The AP Tests

There are two versions of the AP Computer Science test: A and AB. This course is focused toward the A exam. The AB is slightly harder and has a somewhat different focus. If you would like to aim for the AB exam rather than the A, there is an optional project you can do on your own to prepare for it.

As with all AP courses, everyone who takes this course is required to take the exam. It is up to you to decide whether you will work hard enough in this class to pass the exam.

2. Turtles: Learning the Java Language


Basic turtle instructions are
combined to draw shapes.
The Turtles project introduces you to basic ideas of computer graphics programming. A "turtle", in the programming sense, is a simulated creature on your computer screen that can be told to move forward and backward and turn left and right, and which may draw a line as it moves. You will learn how to combine these basic instructions in more and more complicated patterns. Some of the things you can draw with turtle graphics are quite impressive.

Turtles will introduce you to all the basic features of the Java language. You will learn how to create these turtle creatures and other computer "objects", how to use variables to maintain a connection to an object, and how to give that object instructions. Then, you will learn how to put together several instructions to make new instructions of your own, called "methods", and how to put together methods with the information they use to create a "class", a new type of object.

You will also learn strategies for repeating instructions that are done over and over. The two big ways to break down a repetitive problem in a computer program are "loops", which repeat a certain process over and over until something tells them to stop, and "recursion", which breaks down a larger problem into smaller problems.


The Turtles program runs a series of instructions that you
write in Java code. It allows you to see the whole thing
drawn at once, or to step through it slowly.

The Geometer assignment is based on the concept of loops,
the Java way of repeating a process over and over again.
You will find you use a lot of geometry in this class.


Fractals such as this one make use of recursive logic,
breaking up a large problem into smaller parts.


The final project for Turtles asks you to use what
you now know about loops and recursion in solving
several more complicated problems.


3. Asteroids: Creating and Extending Classes


In the Asteroids project, you have complete freedom to
design the rules of your game; I have written the code
that draws everything and gets keyboard input.
In the Asteroids project, Mr. Z. has already created the basic "engine" of a game, but you need to write all the rules that make it go. A GameObject knows how to move around on the screen and how to draw itself, but you will be designing new and special types of GameObjects to represent a space ship, lasers, asteroids, explosions, and so on.

In Java, we call what you are doing here "extending" an existing class. This is something like taking a car and adding on a siren and radio to make it a police car. In this case, you add on to GameObject all the behavior that describes how it is created, how it interacts with other objects, and how it responds to keys being pressed. Because you write all the rules, every group will end up with an entirely different game, reflecting the choices that you made along the way.

4. Vectorized: Figuring out how to organize information in the computer

Computers are useful for more than just doing things and making calculations; they are also able to store information. In a more complicated computer game, it is important to choose the right way to store your information so that you will be able to access it efficiently.

An object model showing a linked list, a data structure that allows
you to collect several objects into a list whose length may be changed.

In this section you will first learn how to use "object models" to map out the relationships between objects in a program. So, for example, if I have a Turtle object, it has to have a reference to some Color object that describes the color it draws with, and a Shape object that describes its shape. You will learn how to design object models, and how to implement these models in code, figuring out how to create the whole structure and how to access the pieces of it. You will also learn about ways to collect together several objects in a list of values, and you will learn various ways that you can interact with such a list.

The end goal of this unit is a project called Vectorized, a simplified version of a "first person shooter" like Halo or Counterstrike. You will use the skills you have learned to design data structures that hold the information about the shape of a three dimensional world, and that keep track of collisions so that the player is prevented from walking through walls.

5. RPG: Using the Java classes

In Vectorized, you had to figure out for yourself how to create things like lists. You would think that by now, someone would have come up with an optimum version of a list that they were ready to share with other people.

This has in fact been done. There are Java "libraries" containing classes that people have found useful again and again. Some of these, like Color, are ones you have already used. In this chapter, you will learn how to use library classes that work in basic roles like lists, and some more complicated classes, like Maps, which form connections from one set of objects to others.

You will use all this to create a role playing game - one of those games where you are direction a character to explore a map, unearthing treasure and slaying monsters. The basic rules of the game are already set, but you have a wide variety of choices of what features you want to support - locks on doors, conversations, special effects, cinematics, and so on.

In this unit, we will also learn principles of good program design - how to design a program from the start in such a way that it will be easy to change and easy to fix, and how to make sure, as you are working, that you are doing things correctly.

6. AP marine biology simulation: Arrays

Computers are often used to simulate situations for scientific purposes. The required project for the AP exam is a simulation of marine biology. Your program will keep track of many fish swimming around in an underwater environment, each looking for food and possibly preying upon the others.

In this section, you will learn how to use "arrays", rectangular arrangements of objects. An array is similar to the matrices that you use in your math classes. Arrays in Java are a simple way to store an ordered collection of objects.

7. Independent Projects

After the AP exam, you have a month and a half left in the class to complete an independent project with a partner of your choice. This might take the form of a modification to one of the existing projects: adding sound to Asteroids would not be difficult, and making Vectorized use textured walls insteady of wireframe would be an ambitious project, but entirely feasible for the better students.

You could also use this time to try to write a new program entirely from scratch, since the only way that you will every really understand how these games work is if you have a chance to design the whole thing yourself. There are several tutorials online that will help you through this process.

As another option, you could use this time to learn another programming language. Now that you know Java, you will find that most computer languages use the same ideas and the same way of thinking even if the syntax is slightly different. Learning a language that is very different from Java, like TI calculator assembly, would do a lot to broaden the perspective you have on how computers work.

The goal of this last section is to push you out into the real world of programming. This class is carefully structured to shield you from having to learn too many complicated things at once, but anyone who expects to go anywhere as a programmer needs to be able to go online and find the information and tutorials that are needed to learn new things. If you can learn how to learn, there will be no limit to where you can go as a programmer.