Due March 24 before 2359

For our second project, we'll be making heavy use of Polymorphism and Exceptions to make a Chess game, which will allow two people to sit at a computer and play Chess against each other. Chess consists of a set of pieces, each of which have their own rules for moving around the board. From a high level, the goal of this project is to create a Piece class, which is the superclass for a Knight class, a Pawn class, etc. Every time a player attempts to make an incorrect move (of which there are many!) an Exception containing a helpful message will be thrown, which will inform the player what went wrong, so they can try again.

Helpful code

A tarball of code, including a Makefile, can be downloaded here. This code includes the Board class, the Location class, and a Chess class (where your main method will go). Unpack this with the command:

  tar -xzf Chess.tgz

It is really important you understand this code before you begin. It is well commented. Javadocs for this code, as well as for the Piece class that you must write yourself can be found here. Note: you need to write, but we give you its javadoc ahead of time, so you should implement the same variables and methods that are in the javadoc.

In the Makefile, every time you create a new class you'd like to include, add it to the list of .class files that make up the variable CLASSES.

The Assignment

You should submit code for the highest step that you achieve in its entirety. Points will only be given to steps that are completed in full. You may not skip steps. Note that these points are not cumulative; that is, if you have a perfect Step 2, you have 50 points (out of 100), not 90.

Some helpful links for this project:

  1. Javadocs for starter code.
  2. The rules of chess.
  3. The unicode characters for chess pieces.

Step 1: 40 pts

Build the game so that the four Rooks appear on the board and can be moved around the board with legal Rook moves. See the picture on the right for what your output should look like. Unlike in real Chess, "jumping" is allowed. In other words, if:

  (target square is on the same row or column as originating square &&
   (target square is empty || target square holds piece of opposite color))

then the move is legal. Otherwise, an IllegalArgumentException is thrown, and the game stops.

To achieve this step, you'll need to write:

The javadocs for are critical to your success. You will also need the unicode characters for chess pieces to implement toString() properly. You can create a String in Java with a unicode character like so: "\u2656"

Note that terminals render the chess characters differently, and what looks white to one terminal might look black to the other.

Step 2: 50 pts

Javadoc annotation must be performed for all of your custom classes. When writing annotation, assume that your audience is the person who will be maintaining your code after you have completed it.

This is worth 10 points of your project's total grade.

Projects that do not use Javadoc annotation cannot earn more than 40 pts max.

Step 3: 60 pts

Add Bishops. "Jumps" are still allowed. Aside from Bishops, the other addition to Step 1 is that when an IllegalArgumentException is thrown, the game does NOT die; instead, the message from the Exception is printed out, and the player is given another attempt to make his/her play.

Step 4: 75 pts

All the Pieces are implemented, with the following non-chess rules:

Step 5: 90 pts

Disallow jumps for any piece except the Knight. For this, you will likely want to add the abstract method mustBeOpen() into Piece (as discussed in the Javadoc). Note that Location has several static methods (like diagLocations, etc) that will be helpful for this.

Step 6: 5 points each

(yes, there is some extra credit possible)

5 points for each of these bullet points. These will ONLY be considered and awarded points if you have a successful Step 5 project.

What to hand in

  1. Write a README that contains what step you achieved and what extra things you've implemented (for example, if you implemented castling, tell us so we know and can test for it).
  2. Submit all of your *.java files, along with the README.
  3. NOTE - do not forget any .java file. We should be able to compile and run with this command: javac && java Chess
  4. Remove the doc folder
  5. Delete any *.class or other unneeded files prior to submitting
  6. Delete all the files created by running javadoc. We will recreate them ourselves.
  7. All of the above must be in a directory named 'Project2'
  8. When you run the submit script, the directory and its contents get zipped and sent to your instructor. Ask for help early if you are having problems running the submit script.

Make sure that you run the correct submit script for your instructor:

Notes 1:

Points may be taken off for poor encapsulation or Javadoc-ing.

START EARLY. You cannot write this program in 1-2 sittings. Start work before Spring Break so you get a feel for the complexity of this assignment.

Notes 2:

Review the course policy statement on Honor and Projects.

Why do we make these rules for Projects? It is true that you can learn a lot about programming by working with another student. That is why we let you collaborate for Labs. The downside is that the relationship is often uneven - one student usually does the bulk of the programming. The weaker student can often skate by an entire semester without really being challenged to program themselves. We insist that everybody program their Projects alone so that we (and you) can identify weak programmers early and get them some extra instruction.


     Asking Professors == OKAY
     Asking other students == BAD