Structures

Study Floating and Docking Windows of MSVS described here. As you work on the below project, demonstrate to the instructor the usage of this feature.

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 header file defines structures and prototypes functions used in the program. You should implement your functions incrementally: start with location functions, then ship functions, then fleet (array of ships) functions. Use the following file to test your implementation. Presently, the file has location functions commented in while ship and fleet functions commented out. Once you implemented and tested your location functions, comment in ship and then fleet functions and test those. Note that successful compilation of this file does not guarantee correct implementation of the functions. It is just a test.

The header file defines two structures:

The header file prototypes the functions to be used in the implementation. You are advised to define (implement) the functions incrementally in the order prototyped in the header file. As you complete a function, invoke it in main() to make sure it works correctly.

The functions are separated into three groups:

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.