CS242: Advanced Programming Concepts in JAVA

Fall 2008

Program 6

Due: 10:00 AM, Monday, 10/013/08

This assignment is to implement a simple command line interface. That is, it allows the user to enter a series of commands to control execution of a program and shows the user the results of each command. This program doesn't have to actually execute the commands (yet); it just accepts commands from the user, checks them for errors, and displays commands in a standard format. Eventually, this kind of interface will be added to your game playing program.

The program should have a class named TestIO which contains the main method. The main() method 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. That means the command can be typed in upper or lower case characters, or a mixture of both.

As each command is read, it is echoed to the screen. That is, it is printed on the screen exactly as it was entered. Then it is reprinted in a standard format to be described below.

The commands are:

  1. start
  2. resume [filename]
    [filename] is a string.
  3. save [filename]
    [filename] is a string.
  4. remove row col
    row and col must be nonnegative integers.
  5. place piece row col
    piece, row, and col must be nonnegative integers.
  6. move fromrow fromcol torow tocol
    fromrow, fromcol, torow, and tocol must be nonnegative inegers.
  7. show row col
    row and col must be nonnegative integers.
  8. display
  9. quit
The program should prompt the user for a command. You can decide how to do this. After the user enters a command, the program will echo it to the screen, and then check that it was a valid command. If it isn't, then an error message is displayed. If it is, then the command is printed out again, but using the following formatting:
After this, the program should repeat the entire process, until a quit command is entered. After processing the quit command, the program terminates. Here is an example. The ">" is the prompt to the user.
>         start
         start
START
>  Move 51     74
  move 51     74
MOVE        51   74
>  moove 34 14
  moove 34 14
Illegal command
>  SAve   g1.gam
  SAve   g1.gam
SAVE     g1.gam
>   placE  4  21  6
   placE  4  21  6
PLACE        4   21    6
>  place  5   -8  2
  place  5   -8  2
Illegal parameter: -8
>quit
quit
QUIT
It is not necessary to use exception handling in this program, but you may want to. You don't need to put the program into a package. The default package is fine.

Add comment documentation to your program 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:
Your grade on the program will be based on: