CS242: Advanced Programming Concepts in JAVA

Fall 2008

Program 7

Due: 10:00 A.M., Monday, 10/20/08

For this assignment, you are to augment Program 5 so that it implements a command line interface. This is not a program that actually plays the game; it just manages a game board for one checkers game.

The structure of your program should follow the structure of Program 5. That is, it should have classes TestCheckers, Game, Checkers, and Board that satisfy the design requirements (class structure, methods, and packaging) specified in Program 5.

This time the main() method needs to manage only a single game. The main() should accept commands from the command line, one command per line. Commands are of the form
command parameter1 parameter2 ....
Optional parameters are indicated by [parameter]. All commands are free-format, i.e., variable spacing before and after commands and parameters, and not case-sensitive. All exceptions should be detected and thrown in the method where they occur, and caught in main(). This will include I/O exceptions and exceptions caused by bad parameter values. You don't need to consider illegal checkers moves (unless you want to). All exception classes that you define should contain variables and methods that enable main() to extract important information about the exception, so that main() can respond appropriately to each exception.

The commands are:

  1. start
    A new game begins, with the pieces placed as they should be at the start of a game.
  2. remove row col
    Removes the piece at (row,col)
  3. place piece row col
    Puts a piece on (row,col). The parameter "piece" is an integer that indicates what kind of piece it is.
  4. move fromrow fromcol torow tocol
    Moves the piece from (fromrow,fromcol) to (torow,tocol).
  5. show row col
    Prints the contents of (row,col) to the screen.
  6. display
    Displays the board on the screen. You can still use simple text output.
  7. quit
    The user is asked whether the game should be saved. If the response is yes, then the program terminates.

Your grade will be based on how well you design and implement the code, how thorough your exception handling is, on good programming practices, and on thorough testing. Coding guidelines for Java programs are posted here.

Add comment documentation to your program (all classes) and use javadoc to extract the documentation into an HTML file. Include a javadoc comment for each class and each method. The class comment should include your name and the date (use the @author tag). Method comments should briefly describe the purpose of the method, its arguments, and what, if anything, it returns (using @param and @return as appropriate).

The physical location of the javadoc comments is critical. A class comment must immediately precede the line containing the keyword class, and method comments must immediately precede the method.

When you have commented your source files, run javadoc to create the .html files and view them in a browser of your choice.


What to submit: