1.Update the start of the preprocessor commands to do the following
a.Include C library stdlib.h
b.Include C library string.h
c.Include C library stdbool.h
d.Modify the value assigned to MANUAL as 49
e.Modify the value assigned to RANDOM as 50
f.Add constant PLAYERONE assigned explicit string "Player 1"
g.Add constant PLAYERTWO assigned explicit string Player 2
h.Remove constant TRUE
i.Remove constant FALSE
2.Before the main function, define the following structures using the typedef statement to create an alias:
a.struct gameboard with member(s)
i.character 2-dimensional array sized 10 x 10, be sure to use defined constants versus hard coding
ii.alias GameBoard
b.struct location with member(s)
i.integer row
ii.integer column
iii.alias Location
c. struct ship with member(s)
i.character array name, size 11
ii.character symbol
iii.integer length
iv.boolean sunk
v.Location start
vi.alias Ship
d.struct human with member(s)
i.character array name, size 20
ii.GameBoard gameBoard
iii.Ship array ships, size 5 (use constant)
iv.alias Player
e.enum ships with values
i.battleship
ii.carrier
iii.cruiser
iv.destroyer
v.submarine
3.Before the main function updated or add the following function prototypes based on their function definitions as described later (you will have to scroll down to find the definitions)
a.displayGameBoard
b.initializePlayer
c.initializeBoard
d.initializeShips
e.displayShips
4.Update function main to do the following
a.Replace the 2-dimensional arrays representing the player gameboards with struct Player, playerOne and playerTwo
b.Replace the calls for each player to functions initializeBoard() and displayGameBoard() with initializePlayer(), pass as arguments respectively
i.Pointer to struct playerOne or playerTwo
ii.Constant for PLAYERONE or PLAYERTWO
c.Remove the scanf() statements to pause the screen
d.Update the switch() statement to modify the printf() statement to
i.Replace explicit text "Human player" with the string format specifier
ii.Add second argument as struct playerOne member name
5.Update function displayMenu to do the following
a.Replace the statement scanf ("%d", &select); so that variable select is set equal to function call getchar() in order to resolve the infinite loop when the user enters a value other than an integer
b.After the if statement to validate the user's input add function call fflush(stdin); to clear the buffer
6.Update function displayGameBoard() to do the following
a.Modify the parameter list so that it includes only a parameter of struct Player named player
b.Modify the printf() statement identifying the player's game board name so that the argument passed is the member name of struct Player
c.Modify the printf() statement in the nested for loop so that it replaces array name board with the struct Players member gameBoard followed by GameBoards member board (e.g. player.gameBoard.board)
7.Add function initializePlayer() to do the following
a.Return type void
b.Parameter list
i.struct Player as a pointer named player for local variable
ii.char as a pointer named name
c.Declare a variable that is a character array named playerName, size 20
d.Declare a variable that is struct GameBoard named playerBoard
e.Declare a variable that is a struct Ship array named ships, size 5 (use the constant NUM_SHIPS)
f.Call function printf() to prompt the user to enter the player's name; use the %s format specifier; pass as the second argument the parameter received as name
g.Call function gets(), pass as an argument the variable playerName
h.Call function strcpy() to copy the player name entered by the user stored in variable playerName into the struct Player member name
i.Set struct Player member gameboard equal to the variable playerBoard
j.Call function memcpy() passing the following arguments
i.struct Player member ships
ii.local variable ships
iii.constant NUM_SHIPS
k.Call function initializeBoard() passing struct Player from the parameter list as an argument
l.Call function displayGameBoard() passing struct Player from the parameter list as an argument; be sure to dereference the pointer
m.Call function getchar() to require the user to enter a keystroke before clearing the screen
n.Call function clearScreen()
o.Call function initializeShips() passing struct Player from the parameter list as an arguement
p.Call function displayShips() passing struct Player from the parameter list as an argument; be sure to dereference the pointer
q.Call function getchar() to require the user to enter a keystroke before clearing the screen
8.Update function initializeBoard() to do the following
a.Modify parameter list to receive struct Player named player
b.Replace the nested for loop with call to function memset() passing as arguments
i.struct Player local name, member GameBoard named gameBoard, member board
ii.constant WATER
iii.operator sizeof() passing as an argument struct Player local name, member GameBoard named gameBoard, member board
9.Write function initializeShips() to do the following
a.Return type void
b.Parameter list struct Player as a pointer named player
c.Declare variable data type integer to use as a looping variable for a for loop
d.Loop through the five ships (use the constant NUM_SHIPS)
i.Declare a variable of struct Ship
ii.Write a switch statement based on the looping variable
1.Write a case label for each of the enumerations in enum ships
a.Call function strcpy() to set the name of the ship
b.Set the ship's length based on its constant
c.Set the ships symbol based on its constant
iii.After the closing brace of the switch statement, do the following
1.Set the ships sunk to false
2.Set the ships start location row to -1
3.Set the ships start location column to -1
4.Add the ship to the struct Players ships array
10.Write function displayShips() to do the following
a.Return type void
b.Parameter list receives struct Player named player
c.Declare variable data type integer to use as a looping variable for a for loop
d.Call function printf() to output the player's name and explicit text "Ship Data"; use the %s format specifier; pass as the second argument the parameter received as struct Player member name
e.Loop through the five ships (use the constant NUM_SHIPS)
i.Write a printf() statement to output the ships name; pass as a second argument the struct Player, member ships[], member name
ii.Write a printf() statement to output the ships length; pass as a second argument the struct Player, member ships[], member length
iii.Write a printf() statement to output the ships symbol; pass as a second argument the struct Player, member ships[], member symbol
iv.Write a printf() statement to output the ships sunk status; pass as a second argument as a ternary operator (i.e. ((condition to evaluate) ? true result : false result)) )
1.condition: the struct Player, member ships[], member sunk
2.true result explicit text True
3.false result explicit text False
v.Write a printf() statement to output the ships location, row and column; pass as a second argument the struct Player, member ships[], member start, member row; pass as a third argument the struct Player, member ships[], member start, member column