CS242: Advanced Programming Concepts in JAVA

Fall 2008

Program 10

Due: 10:00 A.M., Monday, 11/17/08

In this assignment, you are to implement some of the commands that are displayed in the dropdown list under the File menu. These commands should work as they did in Program 8. The only difference is that now the user interacts with the program through graphics components in the window. It can all be done with various kinds of textboxes, but you may also want to use some buttons, checkboxes, or radio buttons. The choice is up to you. The main criterion is that the program should be easy to use. The commands are:

  1. start
    There are three cases:
    (1) No game is in progress. In this case, a new game begins, with the pieces placed as they should be at the start of a game. (You don't have to display the board in this assignment, but your program should initialize whatever variables it uses to represent the board.)
    (2) A game is already in progress, but it has not yet been saved to a file.
    The user is asked if the game should be saved.
    If the user responds yes, then the user is prompted for a filename.
    If the filename already exists, then the user is asked whether the file should be overwritten. If the user responds yes then the game is written to that file.
    If the file does not exist, then it is created and the game is written to that file.
    (It's up to you how this is done. The window could have a textbox for entering the filename, which could also be used to enter "yes" or "Y" or other variation like that, or there could be buttons or some other kind of graphics component. The main criteria are that it uses graphics components and not the command line, and it is easy to use.)
    Then a new game begins, with the pieces placed as they should be at the start of a game.
    (3) A game is already in progress, and it has previously been saved to a file, either during this run of the program or some previous run.
    The user is asked if the game should be saved. If the user responds yes then the game is written to that file.
    Then a new game begins, with the pieces placed as they should be at the start of a game.
  2. resume [filename]
    Three cases:
    (1) No game is in progress. Then the game that was saved in [filename] is read in, and it is resumed. (If no filename was specified, then the user is prompted for it.)
    (2) A game is already in progress, but it has not yet been saved to a file.
    The user is asked if the game should be saved.
    If the user responds yes, then the user is prompted for a filename.
    If the filename already exists, then the user is asked whether the file should be overwritten. If the user responds yes then the game is written to that file.
    If the file does not exist, then it is created and the game is written to that file.
    Then the game that was saved in [filename] is read in, and it is resumed. (If no filename was specified, then the user is prompted for it.)
    (3) A game is already in progress, and it has previously been saved to a file, either during this run of the program or some previous run.
    The user is asked if the game should be saved. If the user responds yes then the game is written to that file.
    Then the game that was saved in [filename] is read in, and it is resumed. (If no filename was specified, then the user is prompted for it.)
  3. save [filename]
    Three cases:
    (1) No game is in progress. This is an error.
    (2) A game is already in progress, but it has not yet been saved to a file.
    If [filename] is not specified, then the user is prompted for a filename.
    If [filename] does not exist, then it is created, and the game is written to that file.
    If [filename] already exists, then the user is asked whether the file should be overwritten. If the user responds yes, then the game is written to that file.
    (3) A game is already in progress and it has previously been saved to a file.
    If [filename] is not specified or it is the same as the file that the game is already saved in, then it is written back to the file.
    If [filename] is specified and it is different from the file that the game is already saved in, and [filename] does not exist, then it is created, and the game is written to that file.
    If [filename] is specified and it is different from the file that the game is already saved in, and [filename] exists then the user is asked whether the file should be overwritten. If the user responds yes then the game is written to that file.
  4. quit
    If no game is in progress, then the program terminates.
    If a game is in progress, then the user is asked whether the game should be saved. If the response is yes, then the game is saved as in the save command. Then the program terminates.

Your program must follow these implementation restrictions:

Your grade will be based on how well you design and implement the code, how thorough your error 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:
Your grade on the program will be based on: