# Battleship game | Computer Science homework help

CMSC 401 Spring 2013 Program 6 – Battleships1 Program name: bs.java ZZ The puzzle described below is a solitaire version of the classic paper and pencil game of Battleships. The grid represents a section of the ocean in which the entire fleet is hiding. This fleet consists of one battleship (four grid squares in length), two cruisers (each three squares long), three destroyers (each two squares long), and four submarines (one square each). The ships may be oriented either horizontally or vertically, and NO TWO SHIPS WILL OCCUPY ADJACENT GRID SQUARES, EVEN DIAGNOLLY. The digits along the right side of and below the grid indicate the number of grid squares in the corresponding rows and columns that are occupied by vessels. In the puzzle, certain “shots” may have been taken to start you off. These may show ocean (O), a complete submarine (U), or the middle (M) or the end (N, S, E, W) of a longer vessel. Your task is to determine where the fleet is located. A sample puzzle is: 1 0 1 N 7 1 M 3 1 O 4 0 2 2 1 1 3 1 4 2 3 1 2 To facilitate data entry, the following will be in effect: 1. Input will be found in a file specified as a command line argument. 2. This file will consist of the following Row 1 10 numeric values representing the “hits for each row. Row 2 10 numeric values representing the “hits for each column. Row 3 a numeric value representing the number of “shots taken. Row 4.. Two integers representing the coordinates of the shot followed by 1 space and a character representing the results of the shot. Indices begin at 0. 3. The results of the shots are as follows O Water U Submarine S The south end of a vertical ship. W The west end of a horizontal ship. N The north end of a vertical ship. E The east end of a horizontal ship. M The middle of a ship (may be either…