Question: I meed help writing a battleship board gane in JAVA. Create the starting board for a game of bsttleship with only one player and one

I meed help writing a battleship board gane in JAVA. Create the starting board for a game of bsttleship with only one player and one ship. There mustbe a program loop to generate a new board with random ship locations horizontally and vertically. The program should run multiole times. The ship should be seen located in all quadrants of the board, every ship covering 5 positions, and again in vertical and horizontial positions each time the game is played. When initializing a board or assigning positions to the ship, a for loop must be used. The "empty" character must be a double dash, not an underscore. The appearance of the board must be square if the number of rows and columns are the same. All emoty space characters MUST be perfectly aligned, especially in the columns to the right of the ship placement. There must be a method called generateBoard that takes the number of rows and columns as an argument that returns a 2D array which is randomly populated with a single ship. This method must use a loop structure to determine the position of the ship. There must be a method called displayBoard that takes a populated array as an argument and creates a popup window displaying the board. The buttons on the popup box should say "Stop Already!" and "Show Another Board". When one of these buttons on the popup is clicked, the methods and returns the option selected by the user determined by the button clicked. All methods must be static and there shoild be NO static variables. Termination display MUST be present in a popup window. This program MUST contain a program loop using the "back door" option that creates new game boards until the user indicates enough. The Boolean expression in loop MUSTbe tied to TRUE. Random util and JOptionPane should be used for the popup windows. Things to remember and should be incorporated in the program are as follows: create a 2D arrat and initilize it with the empty space symbol using a for loop. Determine location and orientation of the ship using random number generating object. Add the ship symbol to the appropriate location of the array. Generate a string accumulator to print the board. Display accumulator to a JOptionPane. This should be repeated using the "back door" method until the user wants to quit. Also the symbol used for the ship is capital X.The popup window should say "New Game Board". There should also be an introduction Popup window. Program should be coded in Java, not Python or C++.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!