Engineering 5895, Software Design

Assignment 1

Problem Statement

We require a Battleship game to be runnable on a Computer.

Description of the game

The game is played by a human against the computer. Each player has an area of "sea" where his fleet exists. Each area of sea consists of an nxn set of squares. Both areas are to be displayed on the screen.

Each player has 1 battleship (5 squares long), 1 heavy cruiser (4 squares long), 1 missile cruiser (3 squares long) and 2 destroyers (2 squares long each). Vessels must occupy contiguous squares and be oriented either horizontally or vertically).

At the beginning of the game each player chooses where to place his/her/its vessels in his/her/its patch of sea. The human players vessels will be visible on the screen while the computer players will not be.

Each player takes turns taking a single shot at the opponent's area. Once a shot is taken the computer displays whether it is a hit or not. A hit occurs when a player shoots at an opponent's square and it contains a (part of a ) vessel.

A vessel is deemed to be sunk when it has taken a hit on every square it occupies.

A win occurs the moment all of one players vessels have been sunk.

No Peeking rule. The computer is not allowed to interrogate a square until a shot has been fired at it.

Squares that have been shot at should be marked automatically. Squares where hits have occurred should be marked automatically.

Available Resources

You get the standard MouseSquare class with the following operations

MouseSquare(x: int, y: int, width: int, height: int)

Constructor. create a visible mouse square of width by height pixels with its top left corner at (x,y) relative to the top left corner of the screen.

fill(color: Color)

fill the interior of the square with the specified color, which can be one of the standard html color strings. A fill will overwrite all pixels in the square including those set by other routines such as setIcon or setText

setIcon(filename: String)

put an icon defined by a gif file located at filename into the mouseSquare. The icon will be centred in the square and clipped if its boundaries overflow the square.

setText(text: String)

put text into the mouseSquare. The text will be left justified in the square and centered vertically. It will be line-wrapped at the right boundary and clipped at the bottom boundary.


clear the mouse square so only its boundary shows.


A mouse click has occurred in the square. Designed to be overridden.

Design Constraints

You will be required to split the design into model and view packages with each side accessing the other through an interface, as follows:


A Use Case Diagram. Use cases should be defined in the description part of the specification.

A Class Diagram showing the structure of your design with all operations and associations. In the spirit of designing to the interface, attributes are not wanted at this stage. Your classes and operations should be commented on in the description part of the specification.

An Interaction Diagram showing the sequences for a single turn (human plus computer).

Designs will be judged based on viability, quality of design, quality of documentation.