CS242: Advanced Programming Concepts in JAVA
Fall 2010
Program 2
Due: 2:00 PM, Monday, 9/6/10
For this assignment you will create a simple Java program. You may work with one partner or
individually on this program. It is also a good idea to use
a browser to view the Java2 API documentation and accustom yourself to using
this resource. This documentation can be easily downloaded (see the link
in Online Resources) so that you have a
local copy.
(a) Following the examples in class, the reading assignments, and the Java Tutorials,
create a "Board" class which models a standard checker or chess board. This should be
in a source file named Board.java, and your class must satisfy the requirements given below;
that is, you are not free to change the names, types, or behavior of the specifications.
A gameboard may be thought of as an 8X8 2-dimensional array.
The rows are numbered 0-7 top to bottom, and the columns are numbered 0-7
left to right. In this assignment, the elements in the
array have only two possible values: empty or occupied (or any pair of
values you prefer, such as 0 or 1, ' ' or '*',
'O' or 'X'). Empty means the there is no game piece on the square; occupied
means there is a game piece on the square.
Your grade will be based on how well you design and implement the code,
on good programming practices, and on thorough testing. Coding guidelines
for Java programs are posted here.
We won't be covering classes and constructors until late this week
or next week, so your program should consist of only one class, which
must be structured as follows:
- The main method should read its String[] args parameter, which should
be a list of those squares in the board that are occupied. Each such square
is indicated by a pair of integers in the range 0-7, separated by a comma. For example, if your
program is called with
java Board 4,3 7,0
this indicates that the two squares at row 4, column 3 and row 7, column 0
are occupied.
- The main method should use a 2-dimensional array to hold the data about
the game board, i. e., which squares are occupied or not. The type of the
array is your choice.
- The main method should output a picture of the board. At this point,
we have only seen the println command, and that's all you need to use,
but you should still produce output that is nice looking, easy to understand, and self-explanatory.
You should decide how your program handles bad data. Just ignoring it is not a good solution.
(b) Add comment documentation to your program
and use javadoc to extract the documentation into an HTML file. Include a javadoc
comment for the Board class. The class comment should include your name
and the date (use the @author tag). Although these are small classes now, and this
may seem like a lot of commenting, we will expand on this assignment at a later date.
The physical location of the javadoc comments is critical. A class comment
must immediately precede the line containing the keyword class.
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 Board.java,
and a printout of your test run or runs. You don't need to turn in a test run
for each possible error that your program detects; one run showing how the program
works when there are no errors and another run showing an example of an error is
fine. 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/fa10
Within this individual directory, create a subdirectory named p2.
Copy only the source file into this directory, not class files or javadoc
files.
So, for example, if your login name was smithjd then the file
Board.java should be copied to
/afs/cu/class/cs242/fa10/smithjd/p2. 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).
Your grade on the program will be based on:
- Correct execution. The program must follow all the specifications above.
The hardcopy of your program's execution should clearly
demonstrate that it does. You may want to turn in hardcopy of more than one execution.
- Correct implementation. The program must follow all the design requirements above, in particular the design of the Board class.
- Error checking. You have to figure out what kinds of errors your program should
check for, and how it should handle them. The hardcopy of your execution should include
examples of these error handling capabilities.
- 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. You should follow the Code Conventions
on matters like indentation and layout of your source code.
Whatever you do, be consistent.
- Appearance of the output. At this point, we haven't covered any of the ways
to generate really nice looking output, but the display method should produce
a picture of the board with all the rows and columns lined up nicely, and any
error messages should be well-formatted and easy to read.
- 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.
-
Plagiarism (copying all or part of any other team's
code) is a serious infraction of Clarkson regulations;
the penalty is a grade of 0 for the first infraction,
a final grade of F for further infractions.