Standalone Battleship Game

Assignment 1
- Standalone Battleship Game Aim:
This project aims to develop a Battleship game using the Java programming language.
The game Battleship is a guessing game played by two people (or one person against the
computer in this assignment). The game is played on one (!) single grid. The grid is
typically a square – usually 10 x 10 – and the individual squares in the grid are identified
by letter and number.
Before play begins, a number of ships must be arranged secretly on the grid. Each ship
occupies a number of consecutive squares on the grid arranged either horizontally or
vertically. The number of squares for each ship is determined by the type of the ship.
The ships cannot overlap (at most one ship can occupy any given square in the grid). The
types and numbers of squares ships occupy are proportional to the grid size according
to the following table.
Type of ship
Aircraft carrier
Battleship
Destroyer
Submarine
Patrol boat
Size
5
4
3
3
2
The application should have various levels of difficulty: difficulty level “easy” sets a grid
of 10x10 with 5 randomly chosen ships, “normal” sets the grid to 15 x 15 with 8
randomly chosen ships, and “hard” creates a grid of 20x20 squares with 8 randomly
chosen ships. The difficulty level must be set before starting the game, and after starting
the application. Therefore, you should not start your application with pre-defined grid
size or difficulty level. After the ships have been positioned the game proceeds in a
series of turns. In each turn, each player (computer after human, after computer etc...)
attempts to “hit” a square from the grid. If the player does not hit a ship (“hole in the
water”), then it’s the next player’s turn, else, he/she has the opportunity to fire again,
and again, until he/she misses or wins. That is, when a player hits a ship, he/she has the
right to play again, until he/she makes a hole in the water. When all squares of a ship
have been hit, then the ship is sunk. Players accumulate points for sinking ships. Only
the player that deals the final blow to a ship is awarded the points. The points
associated to ships are equal to their size. The player with the most points when all
ships have been sunk wins.
Objectives
You must design and implement the proposed specifications of the battleship game.
This version of the game includes the following elements




A Graphical User Interface (standalone application), containing the grid, and any
required buttons or menu bars.
Simple intelligence by which the computer estimates its next move. Randomly
chosen squares is ok, but you will be required to expand this in the second
assignment, so do not omit (!) the underlying structure for being able to
implement and attach another logic later on.
Statistics must be maintained throughout execution (for instance each player’s
hits and misses, squares remaining, accumulated points, etc...) and those should
be outputted on a popup window at the end of the game.
A version of the application which runs as an applet in a browser must also be
provided. Make sure you make the standalone application as modular as
possible so as to facilitate the process of making it into an applet.
Support your design by including diagrams using the UML modelling language
specification. Bear in mind that there might be other diagrams, apart from class
diagrams, required for illustrating your ideas, such as use case diagrams and or activity
diagrams. Make sure that you have properly documented your code, including JavaDoc
documentation.
Team working is not allowed in this assignment. Each student must submit a short
report containing
1. Introduction about the Assignment
Clearly state the description of what you are asked to do.
2. Design of the game
Describe your idea of how to implement this game, and support your idea with
the diagrammatic techniques proposed above.
3. Implementation of the game
Describe how you actually implemented the game. Also do not forget to mention
any problems or pitfalls that you met during the implementation of your
proposing design, and discuss how this ultimately affected the design and/ or
implementation.
4. Testing of the application
Test your application against abnormal user behaviour (e.g., providing wrong
values) and describe how your application performs, if there are any bugs
generated, and so on.
The hard deadline for this assignment is WK3 2009; however, the second assignment
will build on this assignment, so you are advised to submit it earlier, in order to get
some feedback that will help you on your second assignment. We suggest you complete
this assignment (at least the implementation) no later than December 10th.