Gradually, over the course of the semester we will build a working version of Battleship. First the GUI framework, then the controls, then the game, etc. Eventually, you'll be able to play a working game of Battleship, and even include a few bonus features along the way. Keep this in mind as you move forward with your programming (but be careful not to jump ahead. We will introduce a few twists and turns that are very different from the traditional version you are familiar with).
For this assignment, you will be playing with some basic Java Swing components and building a visual framework for the remainder of your semester. You should use the Swing graphics package to create a window that contains the following elements your program will eventually need:
To set the size of your canvas in a FlowLayout, you will probably need
to use: setPreferredSize (new Dimension (width, height))
rather than: setSize (width, height). You can also look
ahead at the Layout.java example for more sophisticated ways to
lay out your window.
You can download the Java software from the link on the course home page and run on your own machine. Or you can run it on the suns from the unix command line. You can also use the machines in the Windows NT lab, where Java should should already be installed. Your code should be portable among all of these platforms, but if there are any incompatibilities, your code must ultimately compile and run on the TA's machine, which will be a Windows PC. We will use this first assignment to discover any incompatibilities we didn't know about.
Note: If you are having trouble running java on your PC, make
sure the CLASSPATH environment variable is not set. Some other
program installations may have set it automatically. In Windows, the
environment variables are in the System control panel under
Advanced / Environment Variables. You may also want to add the
directory where the javac program lives (typically something like
C:\Program Files\Java\jdk1.6.0_07\bin
to your PATH environment variable.
You can add also this directory to your PATH variable temporarily,
just in a single window, by typing set
PATH=%PATH%;C:\...etc... on the command line.
You should follow these general Java programming practices:
And, finally, for uniformity please name your Java class that has your main program in it Main, in file Main.java
Coding style will constitute a increasingly large percentage of your
grade as the semester progresses.
| Drawing area with a shape/drawing | 2 points |
| Control panel with at least one widget. | 2 points |
| Interacting with control panel widget prints out a message to the command line | 2 points |
| State panel | 1.5 points |
| Follows all guidelines in Programming Practices section above | 1 point |
| Adds something more, does something new, or significantly surpasses any of the preceding criteria (e.g., multiple widgets, draw stuff out in the state panel). Don't forget this part! | 1.5 points, see below |
Creating an excellent, nontrivial software application requires creativity beyond what your customers, or professor, can explicitly mandate. In general, great software satisfies a set of general requirements or requests, and then adds something beyond that. Grading for the assignments will reflect this fact. Satisfying exactly the bare minimum for each assignment will merit a grade of approximately 75% or 85%, depending on the specific assignment (15% for this assignment, as listed above). The remaining points will be awarded for additional work that adds the special something. This is not necessarily easy to do. You will be both the software designer and the software developer in this course. It's not just the implementation that is important, but also the design of the application. If you do this, include a brief description in your readme file, as noted in the submission instructions.