1) Your first program

We'll start off by getting your machine set up to build and run Java programs. Then we'll go over the basic usage of the command prompt which is what we'll use to build our programs. And finally we'll create a very simple application which just spits some text out to the screen.

2) Number crunching

A command line app (short for application) is a program that you run from a command prompt. All the interaction with a command line app is accomplished through the keyboard. The program that you created in the last lesson was a command line app, but it didn't do much. In this lesson, we'll create another command line app but this will perform some useful calculations. You'll notice that the prototype is not a command line app. It is a window app. We start with command line apps because they are the easiest to implement. We'll get to using windows in a later lesson.

3) Getting input

So far we've just been able to calculate numbers and show them to the user. Now we want to get the user involved in the program by prompting him for some input. We do this by calling a function which returns a String variable. We then use this String to dynamically create output to dialog with the user.

4) Controlling your program

We'd like to do more than just get input and spit it back out at the user. Here we learn how to analyze the input and respond intelligently.

5) Give a second chance

By now you've created a program that prompts the user for various kinds of input. But what if the user messes up and types the wrong thing. At this point the only thing he can do is restart the program. We will overcome this in this chapter by learning about a very important programming feature called "while loops".

6) Creating a window

Now that we've learned some basics and have gotten our introduction sequence written, lets jump into some window programming. In this lesson we will learn how to create a new window and paint a little red box. It's not very exciting, but it's a start. It will be similar to the one to the one shown here, but will actually come up in its own window (rather than being embedded in a web page). The applet shown here is just an example of what your program will look like.

7) Tracking the unit

In this lesson we will learn how to track information about the unit so that we can change the color of the unit based on input during our startup sequence and even be able to dynamically change its location.

8) Moving with the keyboard

Moving the unit around by prompting for input at the console is tedious to say the least. In this lesson we'll learn how to move the unit around on the board simply by pressing the directional arrows on the keyboard.

9) Putting up obstacles

A wide open board is rather booring and makes the game strategy too simplistic. In this lesson, we'll add some water squares to our map. First we have to paint the water on our map and then we'll have to keep our unit from moving onto those squares.

10) Taking turns

We still haven't really created a game yet. So far we only have a single unit that we can move as much as we want. To have a real game, you need at least two teams and the teams will have to take turns. We will limit each unit to have only two moves per turn. We'll use the 's' key to switch turns. Note that there are no new programming concepts taught in this lesson, but this will be good practice to solidify the concepts already learned. The student should be encouraged to try these tasks on his own before referring to the solutions presented in this lesson.

11) Using images

So far in our games, we've just been painting blocks of color on the screen. This is fine for one unit on an open screen, but now we have two units and water squares as well all represented by different colored blocks. It would be helpful to use images to make it clearer what it is that we're moving around. In this lesson we'll introduce some new classes in the Java API, but other than that it will be pretty simple.

12) Conflict resolution

It's not a real game until we someone wins. In this lesson we will learn how to determine if conflict has occurred. When this happens we'll paint a special image to indicate that battle has engaged and the units can no longer be moved. Then we will use a very simple algorithm for resolving the conflict at the end of the turn. We'll expand on this algorithm latter when things get more interesting with multiple units.

13) Dealing with more units

Dealing with one unit or even one unit per team is pretty simple. When you start to have multiple units per team, things start to get hairy. In this lesson, we'll deal with a fixed number of units per team. This code will lay the foundation for lesson where we'll add cities. With cities we'll be able to have an indeterminate number of units per team.