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:
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.
Do not give me a copy of the javadoc.html files.
Within this individual directory, create a subdirectory named p7. Copy only the source files and an executable JAR file into this directory, not class files or javadoc files. So, for example, if your login name was smithjd then the five files TestCheckers.java, Game.java, Board.java, Checkers.java, TestCheckers.jar, and any other .java files your program uses should be copied to /afs/cu/class/cs242/fa08/smithjd/p7. These directories have permissions set so that no one other than yourself and Prof. Lynch can read the files. You may, of course, use whatever operating system and compiler you wish to develop your code, but the version you turn in, both hardcopy and the files submitted to AFS, must compile and run under JDK 5.0 on the Clarkson Windows operating system.
I should be able to run your program by downloading TestCheckers.jar into any folder and entering the command line
Here is one way to create an executable JAR file.
Assume the file TestCheckers.java contains the method main,
the package Games contains the files Game.java, Checkers.java, Board.java,
and any other .java files needed by the program,
and TestCheckers.java imports the package Games.
Then the program can be compiled by
javac -classpath . TestCheckers.java
and executed by
java -cp . TestCheckers
(The classpath options may not be necessary on your computer.)
When you are satisfied that the program is correct, you can create an executable
JAR file in the following way. First, you must create a manifest file containing
the line
Main-Class: TestCheckers
There must be exactly one space after the :, and the line must be terminated with a new line or return. You can name the manifest
file whatever you want. Suppose it is named Manifest.txt. Next, you create the
JAR file containing the manifest file by
jar cfvm TestCheckers.jar Manifest.txt TestCheckers.class Games/*.class
Then you can execute the JAR file by
java -jar TestCheckers.jar
More information on JAR files may be found in the tutorial Packaging Programs in JAR Files.