Assignment 8: Battleship II
Fall 2007, David Matuszek

Purposes of this assignment:

General idea of the assignment:

In Assignment 5 you created a text-only version of the Battleship game. In that assignment, the Ocean class did all the computational work; the Battleship class managed input and output.

In this assignment you will start with an already written Ocean class--either yours or your new partners, whichever you prefer, but not the one I posted--and replace the Battleship class with one that uses GUIs. You can use my posted OceanTest class, or one of your own. You will need two GUIs, one to create a new game, and one to play the game.

The "ocean" will be displayed as a 10 by 10 grid in a JPanel, and will look somewhat like the following.



As before, your Battleship class will be in charge of input/output. This time, however, the input/output will be graphical.

We will assume two players, the "creator" and the "destroyer." The creator sets up a game by placing all the ships; the destroyer tries to sink them.

Creating a new game

When the program starts, the creator should see an empty ocean. The creator can place ships wherever he/she wants, and can also remove them.

Most of the details of the interface are left up to you. Make the GUI as obvious and intuitive as you can--we will test the program by using it, and you will lose points if it's difficult to figure out what to do.

Playing the game

When the creator is done, the player is presented with an ocean that looks empty, but contains hidden ships.

The player should be able to "shoot at" locations in the ocean by clicking on individual squares with the mouse. (Hint: Add a MouseListener or MouseAdapter to the JFrame. Eclipse can help with the details, or you can read the API. You may need to remove a previous MouseListener.)

Keep the player informed about what is going on.

Most of the details of the interface are left up to you.

Additional requirements:

Due date:

Thursday, November 8, before midnight. Turn in your program electronically, using Blackboard. (See my Instructions for Using Zip Files and Blackboard). Only assignments submitted via Blackboard will be accepted--do not send your program by email. The usual late penalty of 5 points per day (out of 100 points) will apply.