Question: REALLY need HELP with this C program of Battleship instructions below: Functional Decomposition First step is to draw a structure chart to help you understand
REALLY need HELP with this C program of Battleship instructions below:
Functional Decomposition
First step is to draw a structure chart to help you understand the decomposition of functions for this program. Remember to start with the overall problem and break it down into inputs, computations, and outputs. One possible functional decomposition includes the following (Note: you are NOT required to apply these functions in your program!):
Create a function welcome_screen() that displays an initial program welcome message along with the rules of Battleship. (Write in C)
Create a function init_board() that sets each cell in a game board to '0'.
Create a function init_board_manual() that allows the user to place each of the 5 types of ships on his/her game board.
Use the digit 5 to represent the carrier, digit 4 for the cruiser, 3 for the destroyer, 2 for the submarine, and 1 for the patrol boat.
Create a function init_board_auto() that randomly places the 5 types of ships on a given board.
Create a function update() that determines if the shot taken was a hit or a miss. Use the digit 1 to indicate a hit, and -1 to indicate a miss in your guess board.
Create a function is_winner() that determines if a winner exists.
Create a function display_board() that displays a board to the screen. Note that Player1's board should be displayed differently than Player2's board (see above).
Create a function check_if_sunk_ship() that determines if a ship was sunk.
Create a function output_current_move() that writes the position of the shot taken by the current player to the log file. It also writes whether or not it was a hit, miss, and if the ship was sunk.
Create a function output_stats() that writes the statistics collected on each player to the log file.
Other functions that you think are necessary!
A main function that does the following: o Simulates the game of Battleship o Opens an output file battleship.log for writing; o Outputs data to logfile o Outputs stats to logfile o Closes logfile Sample Execution The following sample session demonstrates how your program should work (user input is shown in bold).
***** Welcome to Battleship! *****
Rules of the Game:
1. This is a two player game.
2. Player1 is you and Player2 is the computer.
3. Etc. (You need to list the rest of the rules here.)
Hit enter to start the game!
Enter
(clear the screen)
Please select from the following menu:
1. Enter positions of ships manually.
2. Allow the program to randomly select positions of ships.
1
Please enter the five cells to place the Carrier across:
Enter row: 2
Enter col: 3
Etc
Player2 (Computer's) board has been automatically generated.
Player1 goes first.
Player1's Board:
0 1 2 3 4 5 6 7 8 9
0 - - c c c c c - - -
1 d d - - - - - - - -
2 - - - - - - - - - s
3 - - - - b - - - - s
4 - - - - b - - - - s
5 - - - - b - - - - -
6 - - - - b - - - - -
7 - - - r r r - - - -
8 - - - - - - - - - -
9 - - - - - - - - - -
Player2's Board:
0 1 2 3 4 5 6 7 8 9
0 - - - - - - - - - -
1 - - - - - - - - - -
2 - - - - - - - - - -
3 - - - - - - - - - -
4 - - - - - - - - - -
5 - - - - - - - - - -
6 - - - - - - - - - -
7 - - - - - - - - - -
8 - - - - - - - - - -
9 - - - - - - - - - -
Enter a target row: 2
Enter a target col: 3
(clear screen)
2,3 is a hit!
Player1's Board:
0 1 2 3 4 5 6 7 8 9
0 - - c c c c c - - -
1 d d - - - - - - - -
2 - - - - - - - - - s
3 - - - - b - - - - s
4 - - - - b - - - - s
5 - - - - b - - - - -
6 - - - - b - - - - -
7 - - - r r r - - - -
8 - - - - - - - - - -
9 - - - - - - - - - -
Player2's Board:
0 1 2 3 4 5 6 7 8 9
0 - - - - - - - - - -
1 - - - - - - - - - -
2 - - - * - - - - - -
3 - - - - - - - - - -
4 - - - - - - - - - -
5 - - - - - - - - - -
6 - - - - - - - - - -
7 - - - - - - - - - -
8 - - - - - - - - - -
9 - - - - - - - - - -
Player selects: 9 9
9,9 is a miss!
Hit enter to continue!
Enter
(clear screen)
Player1's Board:
0 1 2 3 4 5 6 7 8 9
0 - - c c c c c - - -
1 d d - - - - - - - -
2 - - - - - - - - - s
3 - - - - b - - - - s
4 - - - - b - - - - s
5 - - - - b - - - - -
6 - - - - b - - - - -
7 - - - r r r - - - -
8 - - - - - - - - - -
9 - - - - - - - - - m
Player2's Board:
0 1 2 3 4 5 6 7 8 9
0 - - - - - - - - - -
1 - - - - - - - - - -
2 - - - * - - - - - -
3 - - - - - - - - - -
4 - - - - - - - - - -
5 - - - - - - - - - -
6 - - - - - - - - - -
7 - - - - - - - - - -
8 - - - - - - - - - -
9 - - - - - - - - - -
Etc...
Player1 Wins! Statistics outputted to logfile successfully!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
