Table of Contents

1. Turtles: Learning the Java language

1.1. Basic operations

In the first few days of class, you will learn the very basics of the Java programming language: how to evaluate mathematical expressions, how to store information in variables, and how to create and communicate with objects, small pieces of computer program that work together to make a program run.

Course Overview
Lesson: Computers speak math (9/8/06)

Lesson: Memory, addresses, and objects (9/11/06)
Lesson: References and Variables (9/12/06)
Lesson: Reading Method Signatures (9/13/06)
Lesson: Operations Review (9/14/06)
Operations Test (50 pts, 9/15/06)

1.2. Defining your own methods

You know now everything you need to create Java instructions. What we need to learn next is how to assemble those instructions into a program that can be run over an over, so that you won't have to type it all in again every time you want to see it run.

So far, you have done all your work in the code pad in CodeMotion. Now you will learn how to edit a Java code file to add new methods and change existing ones.

Lesson: Defining methods (9/18/06)
Lesson: Blocks and scope (9/19/06)
Lesson: Returning a value (9/20/06)
Lesson: Methods as Abstractions (9/21/06)
Lesson: Methods Review (9/22/06)

1.3. Defining a class

Once you understand how to add methods to an existing class such as Sandbox, the next step is to learn how to create a new class that defines an entirely new sort of object.

In order to do this, you will learn how to work with instance variables, which are the variables an object holds on to to define its type, like the red, green, and blue of a Color. You will also learn how to write a constructor, a special method used to create a new object.

When creating a new class, you have the option to build on an existing class rather than starting from scratch. So, for example, you can make a new class that behaves like a Turtle but with a few enhancements. You will learn how to extend a class and override some of its methods to produce new behavior.

Lesson: Defining a class (9/25/06)
Lesson: Instance Variables and Constructors (9/26/06)
Lesson: Overriding Methods (9/27/06)
Lesson: Classes Review (9/28/06)
Classes Test (60 pts, 9/29/06)

1.4. Repeating a process with loops

Quite often you want to repeat a certain process over and over again. Copying and pasting works for this sometimes, but leaves you with long, messy code. A much better solution is to learn to work with loops, programming constructs that tell the computer to repeat a block of code until some condition is met.

In order to understand loops, we will take a more rigorous look at how mathematical expressions are evaluated, and look at a new type of number: a boolean, which is a "true or false" value.

Lesson: Mathematical expressions and conditions (10/2/06)
Lesson: Counting loops (10/3/06)
Lesson: More complicated loops (10/4/06)
Lesson: For loops (10/5/06)

Assignment: Geometer (40 pts, 10/11/06)

1.5. If statements and recursion

Loops are known as control structures because they control which instructions are evaluated and in what order. Another way that you might like to be able to control the evaluation of your code is to make a decision to either do one thing or another, based on some condition. An if statement is the way we do this in Java.

One nice thing that if statements allow us to do is to write recursive methods, methods that, instead of solving a problem all at once, break it down into simpler problems, giving a direct answer only in the most simple cases. Learning how to think recursively is one of the hardest, but most useful, parts of programming; we will be coming back to this idea again and again throughout the year.

Lesson: If statements (10/12/06)
Lesson: Simple recursion (10/13/06)
Lesson: Fractals (10/16/06)

Assignment: FractalTurtle (40 pts, 10/20/06)

Lesson: Loops and Recursion (10/23/06)
Lesson: Recursion Review (10/24/06)
Lesson: Loops Review (10/25/06)
Lesson: Loops and Recursion Review (10/26/06)
Loops and Recursion Test (60 pts, 10/27/06)

1.6. Project: MeshTurtle

Putting together all that we have learned so far, Project: MeshTurtle will require you to use loops and recursion to define a new class of Turtle that can draw a "mesh" of polygons. There are also many, many extensions that you can do on this project using the skills you have learned so far in the Turtles unit.

Lesson: MeshTurtle Introduction (10/30/06)
Project: MeshTurtle (80 pts, 11/9/06)

2. Asteroids

At this point you know almost everything there is to know about the basic syntax of the Java language - how to create and use methods, how to create and use variables, and how to use control structures like if statements and loops.

Most of the complexity of a computer program, however, lies not in the specifics of how a particular method does its job, but rather in the interaction between many different objects, all with different methods. The real job of a programmer is to define different classes of objects and specify how all the classes work together.

You have had some experience already with creating classes. You know how to create instance variables, and how to provide a constructor that sets the initial values of those instance variables. You know that each new class extends an existing class, meaning that it inherits all the methods of its superclass, unless you decide to override a method to change its behavior.

In this section, we will go into these topics in much more depth. The Asteroids game contains many classes of objects that all have to work together under unpredictable circumstances. In Asteroids there are no long complicated tasks like in Turtles that you write a single method to accomplish; rather, the challenge is writing simple methods for your new classes of object, and overriding the methods that are already there, so that somehow all the objects work together and bahave according to the rules you want for your game.

Lesson: Asteroids Introduction (11/13/06)
Lesson: Instance Variables 2 (5 pts, 11/14/06)
Lesson: Constructors 2 (5 pts, 11/15/06)
Lesson: Instance Variables 3 (5 pts, 11/16/06)
Lesson: Overriding Methods 2 (5 pts, 11/17/06)

Lesson: Type (5 pts, 11/20/06)
Lesson: Overriding Methods 3 (11/21/06)

Lesson: Static Methods and Variables (5 pts, 11/27/06)

Now it's time to put together all that we've learned in the first 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 just 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 much different variant of it.
Project: Asteroids

Lesson: Asteroids Review 1 (12/6/06)
Lesson: Asteroids Review 2 (12/7/06)
Asteroids Test (60 pts, 12/8/06)

3. Data Stuctures

In the Turtles project, we were mostly writing single methods to accomplish one particular thing. this is a good way to learn the basics of Java syntax, like methods and loops and recursion, but real Java programming is more complex because it deals with many objects interacting. The Asteroids project is much closer to a real-life programming task, because instead of having one method that does a task from beginning to end, I am trying to write several objects working together to accomplish a more complex goal. A method now is not the entire program; rather, it is one of many behaviors that goes togeterh to define the "personality" of a class.

The next step in complexity is a data structure, an arrangement of many objects, linked together by references in their instance variables, that together represent some more complicated piece of information.

Lesson: Object Models (12/11/06)
Lesson: Using Data Structures (12/12/06)
Lesson: Coding Data Structures (12/13/06)
Lesson: Printing Data Structures (12/14/06)
Lesson: Equating Data Structures (12/15/06)

Lesson: Comparing Data Structures (12/18/06)
Lesson: Data Structures Review (12/19/06)

Data Structures Test (60 pts, 12/21/06)

4. RPG

At this point we have learned all the basic syntax of Java. The rest of the year will be dedicated to learning how to use some particular techniques in Java that are, essentially, the basic tools a programmer has to draw on when making any program.

Project RPG will teach you to use two of these tools. First, we will look in more detail at the String class, learning how to search for information in a String, break it up into pieces, and convert those pieces into numbers to use in your program. This will make it possible for you to read data from a text file to build the data structures in your program. Next, we will look at ArrayList, a class that allows you to store a list of objects and access them by their "index" in the list, so that you don't have to have a unique variable for every object you ever refer to.

Lesson: RPG Introduction (1/3/07)

RPG: Script (10 pts, 1/8/07)
The first part of the project will ask you to make a class Script, representing an object in the RPG world. You will use what you know about comparing objects to write a method that determines whether two scripts match each other.

4.1. ArrayList

The ArrayList class is a library class that allows you to work with a list of objects, all stored in a single variable. You can access each object by its position in the list, known as its index.

Lesson: ArrayList (1/5/07)
Lesson: Using ArrayList 1 (1/8/07)
Lesson: Using ArrayList 2 (1/9/07)
Lesson: Level introduction (1/10/07)

RPG: Level (20 pts, 1/17/07)
In the second part of the project, you will learn how to use ArrayList, a List class that comes with java. You will use this to write Level, the class that contains a list of all the scripts on one screen of the game and allows you to search through them. The Level Checklist contains a quick guide to what the assignment requires.

4.2. Strings and Files

We know from the Data Structures unit how to build strings by joining together various sorts of data. Now we will learn how to "parse" a string and extract that data back into variables. One application of this is to load a program's information from a file.

Lesson: Breaking Up Strings (1/17/07)
Lesson: Parsing Strings (1/18/07)
Lesson: Reading Files (1/19/07)
Lesson: Loading Introduction (1/22/07)

RPG: Loading Files (30 pts, 1/27/07)
In the third part of the project, we will learn a lot more about strings. You know how to put together strings and variables; now you will learn how to take a string apart and extract the numerical information in it. You will use this to make Level load from a file all its scripts and the tiles that make up its terrain. After completing this part, you will have a playable game, although not a terribly interesting one.

Lesson: RPG Project (1/29/07)

RPG: Playing (60 pts, 2/5/07)
You now have developed all the basics that you need for a real RPG game. Tiles and scripts are loaded and the player moves around using my simple code, which has him ignore all obstacles and just go in the direction you told him to. In the final part, you will partner up with another member of the class and get the player to be blocked by walls, to open and close doors, to fight enemies and talk to friends, to pick up objects, to go into other levels, and whatever else you need to make this a fully playable game.

Lesson: RPG Review (2/5/07)
RPG Test (80 pts, 2/6/07)

5. Linked lists

5.1. Making your own List class

One alternative to using an ArrayList is to build your own list somehow. The most common way to do this is a "linked list", a list in which each element has a reference to the next element so that you can reach any element of the list by following these "links". This is of course more complicated than just using ArrayList, and you will as a result use ArrayList for nearly everything you do, but making your own list has the advantage that you have much more control over its behavior.

Lesson: Object Models Review (2/7/07)
Lesson: Linked Lists (2/8/07)
Lesson: Using Linked Lists (2/9/07)

5.2. Abstract Data Types

Once we have a LinkedList class working, we will study in more detail several different ways to access its members. First, you will get it to act as a List, with the same methods that an ArrayList has. Then, we will study some more restrictive ways of accessing the members of the list that are useful in more specific situations: a Stack, Queue, and PriorityQueue.

Lesson: Stack (3/12/07)
Lesson: Queue (2/13/07)
Lesson: Priority Queue (2/14/07)

6. Vectorized

The Vectorized project draws together the things we have learned in the last few units to create a first person shooter. To simplify things, this first person shooter has no textures on the walls and objects; the view simply shows the outlines of the space you are walking around in instead of painting bricks on the walls and tiles on the floors and wrapping "skins" around the objects. However, the basic definition of the environment is exactly the same as you would find in a more modern game.

This project will make use of what you just learned about priority queues - one is used to keep track of pending collisions - and about linked lists - the walls of each room form a linked list. It will also ask you to recall what we learned about designing and implementing data structures, way back in second term, and what we talked about about using and searching through lists, in the RPG project.

Lesson: Vectorized Introduction (2/26/07)

Project: Vectorized (80 pts, 3/12/07)

Lesson: Linked Lists Review (3/12/07)
Lesson: Abstract Data Types (3/13/07)
Lesson: Evaluator (3/14/07)
Lesson: Vectorized Review (3/15/07)

Vectorized Test (50 pts, 3/16/07)

7. Sorting

One particular task that you will often have to do with a list is sorting it - that is, putting the elements in it in order according to some criteria. We will learn several different algorithms for sorting a list, and learn the terminology for comparing them to each other to determine which is more efficient.

Lesson: Bubble Sort (3/19/07)
Lesson: Selection Sort (3/20/07)
Lesson: Insertion Sort (3/21/07)
Lesson: Binary Search (3/22/07)
Lesson: Analyzing Algorithms (3/23/07)
Lesson: Mergesort (3/26/07)
Lesson: Other Sorts (3/27/07)
Lesson: Sorting Review (3/28/07)

Sorting Test (50 pts, 3/30/07)

8. Marine Biology Simulation

The Marine Biology "case study" is a project that all AP Computer Science students work on to prepare for the AP test. A sizeable portion of the test asks questions that require you to be familiar with the code in this case study and to be able to write new code to work with it. We've saved it for last so that it will be fresh in your minds when you take the test, but it really doesn't have all that complicated ideas in it - it is very similar, conceptually, to the RPG project that you already did.

Lesson: MBCS Introduction (4/2/07)
Lesson: MBCS Environment (4/3/07)
Lesson: MBCS Fish (4/4/07)
Lesson: MBCS Testing (4/5/07)
Lesson: Dynamic MBCS (4/9/07)
Lesson: MBCS Subclasses (4/10/07)
Lesson: MBCS Review (4/11/07)
MBCS Test (50 pts, 4/13/07)

9. Review for the AP test

As in most of your other AP classes, we'll review by working through sample AP exams. Your goal should be to complete the exams in the same amount of time you will be allowed on the actual test: 75 minutes for 40 multiple-choice questions, and 105 minutes for four short-answer questions that require you to read and write code in more depth.

My impression from last year is that anyone who can handle the work in this class will have nothing to worry about on the AP exam. One of the nice things about computer science is that if you think you know what you're doing, you probably do - the computer is demanding enough that you really need to understand what's going on to get anything done. So really, this class has focused more on preparing you for real programming than on getting you to pass one exam.

10. Final Projects

We're one of the first AP exams - May 8th. So after the exam, we have more than a month of class left. There's no final exam in this class, because you've already done the AP exam and one high-stress test per class is enough. So, what will we do to get you a grade for fourth term?

At this point, you have all the skills it takes to be an entry-level programmer. What we'd like to do now is to practice those skills by letting you choose a project to work on - something that will require you to learn more about programming (because every professional job involves a lot more learning than doing) but something that will allow you to work toward goals that you set for yourself, instead of the artificial deadlines imposed by this class.

This final project will also ask you to work on one programming-related skill we have neglected so far in this class - the skill of writing coherently about a programming project in a way that communicates the main ideas to someone else. You will write two papers in the course - one a proposal outlining your topic, and the other a final paper detailing what you actually did.

You can read more about the final project here:

Final Project