Program 1
Battleship
due Thursday, February 2nd by the start of lab
Lab Partners
Everyone is encouraged to work with one lab partner (who is in
the same lab section as yourself) on this assignment.
If you do work with a partner, submit one solution with both of your
names on it. Also, please look at the
class
collaboration policy so that you know what is and what isn't
allowed.
General Overview
We are going to implement a simplified version of the classic
game of Battleship. The game will be played on a graphical Java
application.
Objectives
The goal of this assignment is to give you experience designing
a graphical user interface with Java. Furthermore, you will
learn about event-oriented programming.
Game Requirements
- The game is played on an 8 by 8 grid.
- A minesweeper is a boat that
occupies two consecutive horizontal or vertical squares.
- A frigate occupies three consecutive horizontal or vertical squares.
- A cruiser occupies four consecutive horizontal or vertical squares.
- A battleship occupies five consecutive horizontal or vertical squares.
- The computer randomly places one minesweeper, one frigate,
one cruiser and one battleship on the grid at the beginning
of the game.
- The ships may not overlap at all.
- The game displays how many guesses the player has made.
- The game visually distinguishes among unguessed squares,
guessed squares that were misses,
guessed squares that were part of a minesweeper,
guessed squares that were part of a frigate,
guessed squares that were part of a cruiser and
guessed squares that were part of a battleship.
- The game is over, when the user has identified all parts of all ships.
- At the end of the game, the user is asked whether he or she would
like to play again. If the answer is no, the application should end
and the display should disappear. If the answer is yes, a new
random placement of ships should be generated and an empty board
(with 0 guesses) should be displayed.
Note: You are welcome to go beyond this minimal set of requirements if
you would like to produce a more professional version of Battleship.
Grading
- 50%. Correctness.
- 10%. A nice looking, easy to user interface.
- 10%. An appropriately commented solution using Javadoc. Minimally,
use the @author, @version, @param and @return tags.
There should be a program header comment, each method should
have a comment header, all variables and constants should
be commented, tricky code should be commented, etc.
- 30%. An elegant solution. This includes factors such
as good object-oriented design, high quality code (avoid redundancy,
for example), meaningful variable names, etc.
What to Submit
E-mail your code to your lab TA in one message.
The subject of the message
should be: CS221-xx program1 your-names.
The xx is the number of your lab section.
Your lab TA must receive your e-mail by the start of your lab period
on the date on which the assignment is due. Otherwise there
will be a 25 point per day late penalty.