CS242: Advanced Programming Concepts in JAVA
Fall 2008
Program 11
Due: 10:00 A.M., Friday, 12/05/08
In this assignment, you are to extend Program 10 by implementing the commands that are
displayed in the dropdown list under the Play menu and the Help menu.
These commands should work
as they did in Program 7, but with a GUI instead of the command window.
The user should be able to execute them completely without entering any text,
just by using the mouse. How this is done is up to you.
The main criterion is that the program should be easy to use.
The commands are:
- remove
Removes the piece from the selected square.
- place
Places a piece on the selected square.
- move
Moves a piece from one square to another.
- show
Displays the contents of the selected square (empty or the name of the piece)
as text within a graphics component.
Your program must follow these implementation restrictions:
- The current state of the board should always be displayed using graphics
objects, not text. That is, the board should look like a chess board, and the pieces
should be displayed as graphics figures, graphics text, or icons.
Consequently, you don't need to implement the
display command. All the other commands should still be implemented.
- The user will specify board positions and piece values with the mouse,
not with the keyboard. For example, to place a piece on a square, the player would use
the mouse to indicate which square. To indicate which kind of piece is to be
placed on that square, the user could select from a drop down menu, a toolbar, or
some other graphics component. The details are up to you; the main goal is
that the interface should be easy to use and understand, including all responses to
commands, whether or not they were successfully executed.
- The user will still need to be able to enter filenames using text components
for the commands in the File menu.
- The Help function can be very simple. It could just be some text giving a brief summary
of the commands.
-
Your main method should be in a class named TestChess.
- You must use the Java classes in java.awt and javax.swing to implement
your GUI. Some of you may have systems that allow you to "write" GUI programs by using
your mouse to create graphics objects, i.e., without writing code.
Do not do this.
All the code in your program should be text written by you. (Of course, you
will need to import and use many Java classes.)
-
The only time the command window is used is to initiate
execution of the program.
- All game files should be kept in a folder named GameFiles, which should be in
the current directory.
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:
-
Turn in a hardcopy printout of your java source file TestChess.java
and any other .java files your program uses.
Do not give me a copy
of the javadoc.html files.
-
All Java programs will be submitted by copying (or ftping) them to a specially
designated directory in AFS. Each person in the class has a subdirectory
which has the same name as your login
in
/afs/cu/class/cs242/fa08
Within this individual directory, create a subdirectory named p11.
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 files TestChess.java,
TestChess.jar, and any other .java files your program uses
should be copied to
/afs/cu/class/cs242/fa08/smithjd/p11. 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 installed in the Clarkson ITL (our lab room).
I should be able to run your program by downloading TestChess.jar
into any folder and entering the command line
java -jar TestChess.jar
Your grade on the program will be based on:
- Correct execution. The program must follow all the specifications above.
- Correct implementation. The program must follow all the design requirements above.
- Error checking. You have to figure out what kinds of errors your program should
check for, and how it should handle them.
- Readability of the code: commented and well-structured, so that it is
clear what the code is doing.
Use an accepted programming style. The style of the text
is fine, or you can follow the Code Conventions.
Whatever you do, be consistent.
- Appearance of the graphics. I won't try to evaluate the artistic merit of your
graphics. What matters is neatness and clarity.
- Human factors. An inexperienced user should be able to run the program, and the
program should interact with the user with clear, understandable prompts and
responses. This means that the user will always be able to tell whether or not a command
was successfully executed, and if it was not successful, the user is told what the
problem was.
- Timely submission of your program. All hardcopy must be turned in by the deadline.
Late programs will not be accepted. Printouts submitted electronically will be ignored.