3.A.i: The purpose of my program is to create a friendly and competitive way to play Battleship with your friends and people online.

3.A.ii: My game allows the player to click on any square on the battleship grid and then have the game tell you if you hit, missed, or sunk a ship. After the user keeps guessing until they sink all 3 ships, the game will tell the user how many attempts it took for them to sink al 3. Then their score will be used to help them input their data in the leaderboard and will be stored. The leaderboard will adjust using update and delete to make sure the leaderboard stays up to date with all users.

3.A.iii: The inputs are all clicks by the player and they can have different outputs such as hit, miss, or sunk based on the randomized placements of the ships. If you click on a square which does not have a ship on it, it will show a big ‘X’ and let the user know that it was a miss. If you click on a square which does have a ship on it, it will show a ship diagram and let the user know it was a hit. And if 3 ships in a row were to be hit, then it would let the user know that the ship has been sunk. If you have already clicked on a square that has been previously clicked, then it will let the user know that they have already attempted this square and will make sure not to count it towards their score.

3.B.i image

3.B.ii image

3.B.iii: The name of the variable being used in this is usernameInput and scoreInput which will takes the users score and then it will adjust with the leaderboard when inputted which can be organized as lowScore, middleScore, highScore if eligible.

3.B.iv: The data that is being stored in local storage as score represents the number of guesses that the user took to sink all 3 ships. This is important to the functionality of the program as it is able to do the update with the leaderboard and use the score that the user had recieved from the game into the leaderboard which will allow them to compete with other players.

3.C.i: image

3.C.ii: The procedure here is generateShip and generateShipLocations. As the id of the name shows, this function is able to return 3 randomly placed ships in the 7 by 7 grid. It is called in the procedure ship() as it is needed for the important role of randomly repositioning and resizing the ships.

3.D.i: image

3.D.ii: The first call is in the function to randomize the ship’s row in the grid, which is called when the site is loaded. This call takes takes the size of the ships and uses the array given to help place the ship in a random place each time.

3.D.iii: Then it uses generateShipLocations to call in the generateShip variable and use that to place them. It makes sure using the height, width of the gridboxes to make sure all 3 ships can fit and be connected in a straight line (vertical or horizontal).