This document describes the class diagrams for the Battleships project.
The GameServer is the single location where the BattleShipClient can make a request to be attached to a BattleShipServer. Therefore, the GameServer implements a Singleton pattern. The GameServer creates new BattleShipGames and attaches BattleShipClients to them.
The BattleShipClient interacts with the BattleShipGame through the BattleShipServer interface. Once the BattleShipClient has a handle to a BattleShipServer it can register itself with a BattleShipGame. The BattleShipGame implements the Subject design pattern and the BattleShipClient is an Observer. As the BattleShipGame state changes the BattleShipClient is notified.
The BattleShipGame class represents a game shared by two BattleShipPlayers. It contains the common BattleShipMap that represents the current game state. It also contains the BattleShipRules class, which is a Singleton class, that is a lookup point for the rules of the game.
Upon registration with a BattleShipGame, the BattleShipClient receives a reference to a Player interface. It is through this interface that the BattleShipClient is able to interact with the BattleShipPlayer, which represents the individual game player. Each BattleShipPlayer has a Fleet, a MineRepository and a NavalBase. The Player interface gives the BattleShipClient a way to command these resources.
The Player's Fleet consists of two Cruisers, two Destroyers, three Torpedo Boats, and two Minesweepers. The Fleet is the point where the player is able to command these ships. It provides the ability to move, fire, and rotate each ship.
The Cruiser, Destroyer, TorpedoBoat, and Minesweeper are all derived from a common base class called Ship. Ship provides the basic functionality common to all ships. In addition to being derived from Ship the subclasses implement interfaces that indicate they have additional functionality. For example, the Cruiser implements the interfaces GunFunctions and RadarFunctions to indicate that it has guns and radar. Cruiser will contain a Gun and Radar objects, which implement these interfaces. This is a technique that is similar to multiple inheritance known also as a Decorator.
The Player will have a MineRepository. This repository will contain all of the Mines currently owned or known about by the Player. The Minesweeper will place mines, but they come from the MineRepository.
The Player will also have a NavalBase. This is the location where the Ships are repaired. It can also be damaged and repaired.
All items on the Map, like the Ship, NavalBase, Reef, and Mine, implement the MapComponent interface. This interface provides a uniform mechanism for all items on the map to indicate their size, location, and bounding box. This way each square on the map can be checked for a MapComponent. The BattleShipMap is comprised on many MapComponents.
Last Updated: 03/27/2002 17:06:55 pm