Using the JavaDocs an the UML diagrams produced with the too

Using the JavaDocs an the UML diagrams produced with the tools, write a summary description of how the Battleship program is designed. describe the Battleship program. Intwo paragraphs. You do not need to describe every detail, but try to at least describe the primary design of the program, using the UML diagram and JavaDocs for reference.

https://drive.google.com/drive/folders/0B6cq05XhHANlOGR0TVNPamtrRWM?usp=sharing

Battleship numPlayers Integer +Battleship AA nt getNumplayers Player getPlayer(int)() +Section getship (int shipid)() AA, void load Game() AA, void play Game tint Player getScore(int player 0 tvoid displayWinner(int player, int player) +void pla Again Ship places (int position)() Player player: Integer ship: Integer void placeShip (Symbol void player Turn aking Turn setName Computer Player Human Player Clint difficulty: Integer name: String void taking Turn boolean turn: String aking Turn finish Ship G shipNum Integer row: Integer Collum Integer AAA hit shipNum intx)0: Integer fill0: Integer Interface Save reset refresh display

Solution

Initially, the variables are created \'board[5][5]\', which will store the game board, the variable \'ships[3][2]\', which will store the position (row and column) of the 3 hidden ships on the board, the variable \'shot[2]\' that will store the position (row and column) of the shot that the player will take each round, plus the variable \'attempt\', which will store the number of attempts the player has to hit the 3 ships and, finally, the variable \'shotHit\' that counts the number of ships you hit.

Method \'initBoard()\' is triggered, to create the board with the number \'-1\' in all positions.

Once the method is \'initShips()\', which will fill the position of 3 ships (row and column).

This method draws randomly two numbers between 0 and 4. Then it checks if this number is out because no two boats should be placed at the same position.

If it this position have already chosen, the method enter in a do ... while loop that will randomly select the numbers, and only comes out when draws another pair of numbers that is not the location of some ship.

After that, in \'main()\', we start the game.

The games begin using a do ... while loop. In this case, the condition of the loop is \"shotHit! = 3 \'. That is, until you hit the 3 ships, the game goes on.

The first thing that occurs in the loop is to show the board, through the loop \'showBoard()\'.

This method checks each position of the \'board[5][5]\'.

If -1 ,it exhibits water, \'~\'.

If 0, it displays the shot was given and missed, \'*\', and if it is 1, it displays \'X\' indicates that you hit a ship that position.

After showing the board, you will give your shot through the method \'shoot()\', which takes two integers.

Note that the user will enter numbers from 1 to 5, because it counts from 1 to 5.

You, as a Java programmer, that counts from 0 to 4.

Therefore, after the user enters the row and column, SUBTRACT 1 of each of these value.

That is, if user has entered (1.1) in its Java board 5x5, it will represents the position (0.0).

After the shot was given, our game in Java will check if that shot hit a ship. This is done with the method \'hit()\', which returns \'true\' if set and \'false\' case err.

In the method, it simply checks if the pair of values - \'shooting[2]\' - that define your shot, hit with some of the values that define the position of ships - ships[3] [2].

If hit, the value of \'shotHit\' increases.

Hitting or missing, \'attempts\' increases, because an attempt was made.

Hitting or missing, a tip is also displayed. This tip is displayed through the method \'hint()\', which will look at your \'shot[2]\', and look up the row and column you tried to ship some over there, picking the \'ships[3][2] \'.

Note that the row of your shot is \'shot [0]\' and the column is \'shot [1]\'.

The line of each ship is \'ships[x][0]\' column and each ship is \'ships[x][1]\', where \'x\' is the number of the ship. In our case, are three ships, ie ranging from 0 to 2.

Hitting or missing, the board will be changed. The shot you took that spot will change the board, will appear as shot \'*\' or shot that hit \'X\'.

We will do this through the method \'changeBoard()\'.

Here, we use a method inside the other. Thing that we have explained in our Java course.

We checked whether the shot given \'shoot[2]\' struck by the method that we have used and explained, \'hit()\'.

If hit, the board position for the shot you gave will change from \'-1\' to \'1 \'.

If err, the board position for the shot you gave will change from \'-1\' to \'0 \'.

So when the board is displayed, display with \'*\' or \'X\' in place of this ancient \'~\'.

It is challenging for you make a game Battleship, but human x human.

The game is turn based. Create a variable called \'shift\' that is incremented each round, and use the remainder of the division by 2 to know whose turn it is.

For example, if

turn = 1 -> turn % 2 = 1 -> first player\'s turn

turn = 2 -> turn % 2 = 0 -> player 2

turn = 3 -> turn % 2 = 1 -> player 1

turn = 4 -> turn % 2 = 0 -> player 2

...

Create two variables \'board\', two \'attempts\', two \'ships\' and two \'hits\' on different variables to store the data for each user. Or just Oriented Object programming.

The game ends when one of the variables \'hits\' is 3.

Or you can change the board size, the number of ships, etc ... tip your creativity is what counts.

Using the JavaDocs an the UML diagrams produced with the tools, write a summary description of how the Battleship program is designed. describe the Battleship p
Using the JavaDocs an the UML diagrams produced with the tools, write a summary description of how the Battleship program is designed. describe the Battleship p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site