Structures

Study automatic code completion feature with Eclipse/CDT described here. As you work on the below project, demonstrate to the lab instructor automatic code completion with either looping constructs or structures.

Battleship. Create a project titled Lab8_Battleship. You are to program a simplified version of the Battleship guessing game. The field (ocean) is a square 5x5 grid. One of the coordinates of the grid is a number (from 1 to 5) and the other -- a letter (from 'a' to 'e'). Your program should randomly place a fleet of five ships in the ocean. Each ship takes up exactly one location in the ocean. Multiple ships cannot be placed in the same location. The ships, however, can be placed in adjacent locations. The user fires on the ships by specifying the coordinates of the shot. The program reports whether each shot was a hit or a miss. If the shot was a hit, the ship is sunk. The game continues until all ships are sunk. The program does not keep track of the locations of the previously fired shots.

You should use this header file. The file defines two structures:

The header file prototypes the functions to be used in the implementation. The functions are separated into three groups:

You are free to modify the existing functions or introduce new ones. For example, you may elect to pass battleship array size as a parameter to functions as opposed to using a global constant. Make sure your programs adhere to proper programming style. Submit your projects to the subversion repository. Do not forget to verify your submission on the web.