Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

BATTLESHIP PROGRAM IN C using multidimensional arrays, loops and external files.

ID: 675191 • Letter: B

Question

BATTLESHIP PROGRAM IN C

using multidimensional arrays, loops and external files.

Requirements:

Create a single player game of Battleship. There will be a file that the user defines externally called “gameInput”. This input file specifies the position of ships on the board. The player will play the game by entering locations of possible ships. If the player enters a location that a ship has been place it is considered a “hit” otherwise it is a "miss". Game will continue until the player has sunk all the ships, at which time, the game is complete. To validate the user prowess and the performance of your application, all activities of the game will be logged. These logs will be captured in an external file named “gameLog”. The detailed requirements have been specified below.

Game board requirements (gameInput file)

File is to be named “gameInput”

1) 5 x 5 grid of binary digits {0,1}

2) 5 columns

3) 5 rows

4) 0 represents no ship

5) 1 represents a ship

6) Newline represents next row

7) EOF end of game board (not entered by user)

Game Play requirements

Game continues until all ships are sunken

On game start get player name

Newline should display “Please enter your first name: “

Player should be prompted on a new line “Select a Position then press enter: “

Input will be in the form of two single digit numbers separated by a space

Possible single digit input is the set {0 1 2 3 4}

This should occur every player turn until game is complete

Result of entered position should be shown on a new line

If ship was hit user is prompted “Hit!”

If ship was missed user is prompted “Missed!”

Player should then continue to next turn or end game

Player selects a previous position

On new line display “Already Selected”

Player should then continue to next turn

If all ships positions have been selected game ends

User is prompted “You have sunk the fleet!”

Program is complete

Log (gameLog file)

Game start will be logged

The line will display “Game started by user: @“

i.Where @ is the users name

Every turn will be logged on a new line

First field will display “Entered: @,@”

i.Where @ is a 1 digit number

Second field should display “Classified: @”

i.Where @ is “miss” or “hit” or “Already selected”

If game has completed display “Game Complete”

Log file will aggregate activities

Past game logs should not be overwritten

Explanation / Answer

I think this is an mini project.. and here we have just 2 hrs to solve your questions please post the questions which can be completed by 2 hrs.. becz this will take minimum 4 to 5hrs to develop and test and send to you the correct version of code.