// Programmer: Paul Adcock //
// Project: GUI Project //
// Last Modification Date: 05/10/10 //
/* The projects makes 100 shoot buttons, though all may not be needed. It then
puts them in an array and later sets the ones visible accordinly to the array size. My
if statements will keep asking user for a value between 2 and 10 till they do it. Then I'm
going to put the battleship in the array and then going to have actionEvent deal with if it's
not a hit and has a text of 0, I set them default to 0, then it changes the text of that button to an M.
If they shoot there again one or more times, it changes it to an A. If they actually hit the battleship, it changes the text to
an H, shows the number of shots, and then exits. If they surrender, it asks them if they want to, and if they do, it shows the number of shots
and then exits. If they quit, it asks them if they want to, and if they do, it justs says a goodbye message and exits. */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import java.util.*;
import java.io.*;
import java.awt.Component;
public class BattleshipGUI extends JFrame
implements ActionListener
{ // beginning of class
// label
private JLabel shotsLabel, arraySizeLabel;
// area where text is displayed and user would normally enter text but I have made it so the user can't alter the shot count.
private JTextField shotsTF, arraySizeTF;
JFrame frame;
// buttons
public JButton shoot1B, shoot2B, shoot3B, shoot4B, shoot5B,
shoot6B, shoot7B, shoot8B, shoot9B, shoot10B, shoot11B, shoot12B,
shoot13B, shoot14B, shoot15B, shoot16B, shoot17B, shoot18B, shoot19B,
shoot20B, shoot21B, shoot22B, shoot23B, shoot24B, shoot25B, shoot26B,
shoot27B, shoot28B, shoot29B, shoot30B, shoot31B, shoot32B, shoot33B,
shoot34B, shoot35B, shoot36B, shoot37B, shoot38B, shoot39B, shoot40B,
shoot41B, shoot42B, shoot43B, shoot44B, shoot45B, shoot46B, shoot47B,
shoot48B, shoot49B, shoot50B, shoot51B, shoot52B, shoot53B, shoot54B,
shoot55B, shoot56B, shoot57B, shoot58B, shoot59B, shoot60B, shoot61B,
shoot62B, shoot63B, shoot64B, shoot65B, shoot66B, shoot67B, shoot68B,
shoot69B, shoot70B, shoot71B, shoot72B, shoot73B, shoot74B, shoot75B,
shoot76B, shoot77B, shoot78B, shoot79B, shoot80B, shoot81B, shoot82B,
shoot83B, shoot84B, shoot85B, shoot86B, shoot87B, shoot88B, shoot89B,
shoot90B, shoot91B, shoot92B, shoot93B, shoot94B, shoot95B, shoot96B,
shoot97B, shoot98B, shoot99B, shoot100B, surrenderB, quitB, yesB;
private static final int WIDTH = 500;
private static final int HEIGHT = 500;
public BattleshipGUI()
{ // beginning of constructor
setTitle("Battleship Game");
Container pane = getContentPane();
pane.setLayout(new GridLayout(11, 11));
// makes Label for shots
shotsLabel = new JLabel("Shots: ",
SwingConstants.RIGHT);
arraySizeLabel = new JLabel("Array Size: " ,
SwingConstants.RIGHT);
// makes Text Field for shots and makes the text field non-editable
shotsTF = new JTextField(7);
shotsTF.setEditable(false);
arraySizeTF = new JTextField(2);
arraySizeTF.setEditable(false);
// makes the buttons and sets their value initially to 0 and makes the method actionPerformed
// a method of the class BattleshipGUI. I don't need individual handlers.
shoot1B = new JButton("0");
shoot1B.addActionListener(this);
shoot2B = new JButton("0");
shoot2B.addActionListener(this);
shoot3B = new JButton("0");
shoot3B.addActionListener(this);
shoot4B = new JButton("0");
shoot4B.addActionListener(this);
shoot5B = new JButton("0");
shoot5B.addActionListener(this);
shoot6B = new JButton("0");
shoot6B.addActionListener(this);
shoot7B = new JButton("0");
shoot7B.addActionListener(this);
shoot8B = new JButton("0");
shoot8B.addActionListener(this);
shoot9B = new JButton("0");
shoot9B.addActionListener(this);
shoot10B = new JButton("0");
shoot10B.addActionListener(this);
shoot11B = new JButton("0");
shoot11B.addActionListener(this);
shoot12B = new JButton("0");
shoot12B.addActionListener(this);
shoot13B = new JButton("0");
shoot13B.addActionListener(this);
shoot14B = new JButton("0");
shoot14B.addActionListener(this);
shoot15B = new JButton("0");
shoot15B.addActionListener(this);
shoot16B = new JButton("0");
shoot16B.addActionListener(this);
shoot17B = new JButton("0");
shoot17B.addActionListener(this);
shoot18B = new JButton("0");
shoot18B.addActionListener(this);
shoot19B = new JButton("0");
shoot19B.addActionListener(this);
shoot20B = new JButton("0");
shoot20B.addActionListener(this);
shoot21B = new JButton("0");
shoot21B.addActionListener(this);
shoot22B = new JButton("0");
shoot22B.addActionListener(this);
shoot23B = new JButton("0");
shoot23B.addActionListener(this);
shoot24B = new JButton("0");
shoot24B.addActionListener(this);
shoot25B = new JButton("0");
shoot25B.addActionListener(this);
shoot26B = new JButton("0");
shoot26B.addActionListener(this);
shoot27B = new JButton("0");
shoot27B.addActionListener(this);
shoot28B = new JButton("0");
shoot28B.addActionListener(this);
shoot29B = new JButton("0");
shoot29B.addActionListener(this);
shoot30B = new JButton("0");
shoot30B.addActionListener(this);
shoot31B = new JButton("0");
shoot31B.addActionListener(this);
shoot32B = new JButton("0");
shoot32B.addActionListener(this);
shoot33B = new JButton("0");
shoot33B.addActionListener(this);
shoot34B = new JButton("0");
shoot34B.addActionListener(this);
shoot35B = new JButton("0");
shoot35B.addActionListener(this);
shoot36B = new JButton("0");
shoot36B.addActionListener(this);
shoot37B = new JButton("0");
shoot37B.addActionListener(this);
shoot38B = new JButton("0");
shoot38B.addActionListener(this);
shoot39B = new JButton("0");
shoot39B.addActionListener(this);
shoot40B = new JButton("0");
shoot40B.addActionListener(this);
shoot41B = new JButton("0");
shoot41B.addActionListener(this);
shoot42B = new JButton("0");
shoot42B.addActionListener(this);
shoot43B = new JButton("0");
shoot43B.addActionListener(this);
shoot44B = new JButton("0");
shoot44B.addActionListener(this);
shoot45B = new JButton("0");
shoot45B.addActionListener(this);
shoot46B = new JButton("0");
shoot46B.addActionListener(this);
shoot47B = new JButton("0");
shoot47B.addActionListener(this);
shoot48B = new JButton("0");
shoot48B.addActionListener(this);
shoot49B = new JButton("0");
shoot49B.addActionListener(this);
shoot50B = new JButton("0");
shoot50B.addActionListener(this);
shoot51B = new JButton("0");
shoot51B.addActionListener(this);
shoot52B = new JButton("0");
shoot52B.addActionListener(this);
shoot53B = new JButton("0");
shoot53B.addActionListener(this);
shoot54B = new JButton("0");
shoot54B.addActionListener(this);
shoot55B = new JButton("0");
shoot55B.addActionListener(this);
shoot56B = new JButton("0");
shoot56B.addActionListener(this);
shoot57B = new JButton("0");
shoot57B.addActionListener(this);
shoot58B = new JButton("0");
shoot58B.addActionListener(this);
shoot59B = new JButton("0");
shoot59B.addActionListener(this);
shoot60B = new JButton("0");
shoot60B.addActionListener(this);
shoot61B = new JButton("0");
shoot61B.addActionListener(this);
shoot62B = new JButton("0");
shoot62B.addActionListener(this);
shoot63B = new JButton("0");
shoot63B.addActionListener(this);
shoot64B = new JButton("0");
shoot64B.addActionListener(this);
shoot65B = new JButton("0");
shoot65B.addActionListener(this);
shoot66B = new JButton("0");
shoot66B.addActionListener(this);
shoot67B = new JButton("0");
shoot67B.addActionListener(this);
shoot68B = new JButton("0");
shoot68B.addActionListener(this);
shoot69B = new JButton("0");
shoot69B.addActionListener(this);
shoot70B = new JButton("0");
shoot70B.addActionListener(this);
shoot71B = new JButton("0");
shoot71B.addActionListener(this);
shoot72B = new JButton("0");
shoot72B.addActionListener(this);
shoot73B = new JButton("0");
shoot73B.addActionListener(this);
shoot74B = new JButton("0");
shoot74B.addActionListener(this);
shoot75B = new JButton("0");
shoot75B.addActionListener(this);
shoot76B = new JButton("0");
shoot76B.addActionListener(this);
shoot77B = new JButton("0");
shoot77B.addActionListener(this);
shoot78B = new JButton("0");
shoot78B.addActionListener(this);
shoot79B = new JButton("0");
shoot79B.addActionListener(this);
shoot80B = new JButton("0");
shoot80B.addActionListener(this);
shoot81B = new JButton("0");
shoot81B.addActionListener(this);
shoot82B = new JButton("0");
shoot82B.addActionListener(this);
shoot83B = new JButton("0");
shoot83B.addActionListener(this);
shoot84B = new JButton("0");
shoot84B.addActionListener(this);
shoot85B = new JButton("0");
shoot85B.addActionListener(this);
shoot86B = new JButton("0");
shoot86B.addActionListener(this);
shoot87B = new JButton("0");
shoot87B.addActionListener(this);
shoot88B = new JButton("0");
shoot88B.addActionListener(this);
shoot89B = new JButton("0");
shoot89B.addActionListener(this);
shoot90B = new JButton("0");
shoot90B.addActionListener(this);
shoot91B = new JButton("0");
shoot91B.addActionListener(this);
shoot92B = new JButton("0");
shoot92B.addActionListener(this);
shoot93B = new JButton("0");
shoot93B.addActionListener(this);
shoot94B = new JButton("0");
shoot94B.addActionListener(this);
shoot95B = new JButton("0");
shoot95B.addActionListener(this);
shoot96B = new JButton("0");
shoot96B.addActionListener(this);
shoot97B = new JButton("0");
shoot97B.addActionListener(this);
shoot98B = new JButton("0");
shoot98B.addActionListener(this);
shoot99B = new JButton("0");
shoot99B.addActionListener(this);
shoot100B = new JButton("0");
shoot100B.addActionListener(this);
surrenderB = new JButton("Surrender");
surrenderB.addActionListener(this);
quitB = new JButton("Quit");
quitB.addActionListener(this);
// n is the size of the grid
int n = 0;
String gridSizeStr, outputStr;
boolean isInRange = false;
// while loop and boolean allow user to keep entering int values till n is between 2 and 10. Also, it makes certain
// buttons part of the array of buttons so that I can make it in a square shape, though I also need to take care of the
// set visible thing, which I have, and also so I can place the battleship in the array and later use actionListeners to
// change the text to either a M, an A, or a H.
// actually puts the buttons in the interface and on the pane
pane.add(shoot1B);
pane.add(shoot2B);
pane.add(shoot3B);
pane.add(shoot4B);
pane.add(shoot5B);
pane.add(shoot6B);
pane.add(shoot7B);
pane.add(shoot8B);
pane.add(shoot9B);
pane.add(shoot10B);
pane.add(shoot11B);
pane.add(shoot12B);
pane.add(shoot13B);
pane.add(shoot14B);
pane.add(shoot15B);
pane.add(shoot16B);
pane.add(shoot17B);
pane.add(shoot18B);
pane.add(shoot19B);
pane.add(shoot20B);
pane.add(shoot21B);
pane.add(shoot22B);
pane.add(shoot23B);
pane.add(shoot24B);
pane.add(shoot25B);
pane.add(shoot26B);
pane.add(shoot27B);
pane.add(shoot28B);
pane.add(shoot29B);
pane.add(shoot30B);
pane.add(shoot31B);
pane.add(shoot32B);
pane.add(shoot33B);
pane.add(shoot34B);
pane.add(shoot35B);
pane.add(shoot36B);
pane.add(shoot37B);
pane.add(shoot38B);
pane.add(shoot39B);
pane.add(shoot40B);
pane.add(shoot41B);
pane.add(shoot42B);
pane.add(shoot43B);
pane.add(shoot44B);
pane.add(shoot45B);
pane.add(shoot46B);
pane.add(shoot47B);
pane.add(shoot48B);
pane.add(shoot49B);
pane.add(shoot50B);
pane.add(shoot51B);
pane.add(shoot52B);
pane.add(shoot53B);
pane.add(shoot54B);
pane.add(shoot55B);
pane.add(shoot56B);
pane.add(shoot57B);
pane.add(shoot58B);
pane.add(shoot59B);
pane.add(shoot60B);
pane.add(shoot61B);
pane.add(shoot62B);
pane.add(shoot63B);
pane.add(shoot64B);
pane.add(shoot65B);
pane.add(shoot66B);
pane.add(shoot67B);
pane.add(shoot68B);
pane.add(shoot69B);
pane.add(shoot70B);
pane.add(shoot71B);
pane.add(shoot72B);
pane.add(shoot73B);
pane.add(shoot74B);
pane.add(shoot75B);
pane.add(shoot76B);
pane.add(shoot77B);
pane.add(shoot78B);
pane.add(shoot79B);
pane.add(shoot80B);
pane.add(shoot81B);
pane.add(shoot82B);
pane.add(shoot83B);
pane.add(shoot84B);
pane.add(shoot85B);
pane.add(shoot86B);
pane.add(shoot87B);
pane.add(shoot88B);
pane.add(shoot89B);
pane.add(shoot90B);
pane.add(shoot91B);
pane.add(shoot92B);
pane.add(shoot93B);
pane.add(shoot94B);
pane.add(shoot95B);
pane.add(shoot96B);
pane.add(shoot97B);
pane.add(shoot98B);
pane.add(shoot99B);
pane.add(shoot100B);
pane.add(surrenderB);
pane.add(quitB);
pane.add(shotsLabel);
pane.add(shotsTF);
pane.add(arraySizeLabel);
pane.add(arraySizeTF);
shotsTF.setText("0");
boolean isValid = false;
while (isValid == false)
{ // beginning of while
try
{ // beginning of try
gridSizeStr = JOptionPane.showInputDialog("Enter the size of the grid:");
n = Integer.parseInt(gridSizeStr);
Integer storeValue;
storeValue = n;
arraySizeTF.setText(storeValue.toString());
if (n < 2)
throw new MyTooSmallException();
if (n > 10)
throw new MyTooBigException();
isValid = true;
} // end of try
catch ( MyTooSmallException mtse)
{ // beginning of catch
JOptionPane.showMessageDialog(null, "Enter a value that is not less than"
+ " 2 and is no greater than 10. " +"\n " + mtse.toString() );
} // end of catch
catch ( MyTooBigException mtbe)
{ // beginning of catch
JOptionPane.showMessageDialog(null, "Enter a value that is not less than"
+ "2 and is no greater than 10. " +"\n " + mtbe.toString() );
} // end of catch
catch (NumberFormatException nfeRef) //Line 13
{ // beginning of catch
JOptionPane.showMessageDialog(null,
"Enter an integer. Exception "
+ nfeRef.toString(),
"NumberFormatException",
JOptionPane.ERROR_MESSAGE); //Line 14
} // end of catch
} // end of while
if (n >=2 && n <= 10)
{ // beginning of if
JButton[][] arrayOfButtons = new JButton[n][n];
for (int i = 0; i < arrayOfButtons.length; i++)
{
for (int j = 0; j < arrayOfButtons[i].length; j++)
arrayOfButtons[i][j] = new JButton();
}
char [][] charArray = new char[n][n];
for ( int x = 0; x < charArray.length; x++)
{
for ( int y = 0; y < charArray[x].length; y++)
charArray[x][y] = '0';
}
// hopefully these two for loop sets will make them parallel arrays
if ( n == 2)
{ // beginning of if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
} // end of if
else if (n == 3)
{ // beginning of else if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
} // end of else if
else if (n == 4)
{ // beginning of else if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[0][3] = shoot4B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[1][3] = shoot14B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
arrayOfButtons[2][3] = shoot24B;
arrayOfButtons[3][0] = shoot31B;
arrayOfButtons[3][1] = shoot32B;
arrayOfButtons[3][2] = shoot33B;
arrayOfButtons[3][3] = shoot34B;
} // end of else if
else if (n ==5)
{ // beginning of else if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[0][3] = shoot4B;
arrayOfButtons[0][4] = shoot5B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[1][3] = shoot14B;
arrayOfButtons[1][4] = shoot15B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
arrayOfButtons[2][3] = shoot24B;
arrayOfButtons[2][4] = shoot25B;
arrayOfButtons[3][0] = shoot31B;
arrayOfButtons[3][1] = shoot32B;
arrayOfButtons[3][2] = shoot33B;
arrayOfButtons[3][3] = shoot34B;
arrayOfButtons[3][4] = shoot35B;
arrayOfButtons[4][0] = shoot41B;
arrayOfButtons[4][1] = shoot42B;
arrayOfButtons[4][2] = shoot43B;
arrayOfButtons[4][3] = shoot44B;
arrayOfButtons[4][4] = shoot45B;
} // end of else if
else if (n == 6)
{ // beginning of else if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[0][3] = shoot4B;
arrayOfButtons[0][4] = shoot5B;
arrayOfButtons[0][5] = shoot6B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[1][3] = shoot14B;
arrayOfButtons[1][4] = shoot15B;
arrayOfButtons[1][5] = shoot16B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
arrayOfButtons[2][3] = shoot24B;
arrayOfButtons[2][4] = shoot25B;
arrayOfButtons[2][5] = shoot26B;
arrayOfButtons[3][0] = shoot31B;
arrayOfButtons[3][1] = shoot32B;
arrayOfButtons[3][2] = shoot33B;
arrayOfButtons[3][3] = shoot34B;
arrayOfButtons[3][4] = shoot35B;
arrayOfButtons[3][5] = shoot36B;
arrayOfButtons[4][0] = shoot41B;
arrayOfButtons[4][1] = shoot42B;
arrayOfButtons[4][2] = shoot43B;
arrayOfButtons[4][3] = shoot44B;
arrayOfButtons[4][4] = shoot45B;
arrayOfButtons[4][5] = shoot46B;
arrayOfButtons[5][0] = shoot51B;
arrayOfButtons[5][1] = shoot52B;
arrayOfButtons[5][2] = shoot53B;
arrayOfButtons[5][3] = shoot54B;
arrayOfButtons[5][4] = shoot55B;
arrayOfButtons[5][5] = shoot56B;
} // end of else if
else if (n == 7)
{ // beginning of else if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[0][3] = shoot4B;
arrayOfButtons[0][4] = shoot5B;
arrayOfButtons[0][5] = shoot6B;
arrayOfButtons[0][6] = shoot7B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[1][3] = shoot14B;
arrayOfButtons[1][4] = shoot15B;
arrayOfButtons[1][5] = shoot16B;
arrayOfButtons[1][6] = shoot17B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
arrayOfButtons[2][3] = shoot24B;
arrayOfButtons[2][4] = shoot25B;
arrayOfButtons[2][5] = shoot26B;
arrayOfButtons[2][6] = shoot27B;
arrayOfButtons[3][0] = shoot31B;
arrayOfButtons[3][1] = shoot32B;
arrayOfButtons[3][2] = shoot33B;
arrayOfButtons[3][3] = shoot34B;
arrayOfButtons[3][4] = shoot35B;
arrayOfButtons[3][5] = shoot36B;
arrayOfButtons[3][6] = shoot37B;
arrayOfButtons[4][0] = shoot41B;
arrayOfButtons[4][1] = shoot42B;
arrayOfButtons[4][2] = shoot43B;
arrayOfButtons[4][3] = shoot44B;
arrayOfButtons[4][4] = shoot45B;
arrayOfButtons[4][5] = shoot46B;
arrayOfButtons[4][6] = shoot47B;
arrayOfButtons[5][0] = shoot51B;
arrayOfButtons[5][1] = shoot52B;
arrayOfButtons[5][2] = shoot53B;
arrayOfButtons[5][3] = shoot54B;
arrayOfButtons[5][4] = shoot55B;
arrayOfButtons[5][5] = shoot56B;
arrayOfButtons[5][6] = shoot57B;
arrayOfButtons[6][0] = shoot61B;
arrayOfButtons[6][1] = shoot62B;
arrayOfButtons[6][2] = shoot63B;
arrayOfButtons[6][3] = shoot64B;
arrayOfButtons[6][4] = shoot65B;
arrayOfButtons[6][5] = shoot66B;
arrayOfButtons[6][6] = shoot67B;
} // end of else if
else if (n == 8)
{ // beginning of else if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[0][3] = shoot4B;
arrayOfButtons[0][4] = shoot5B;
arrayOfButtons[0][5] = shoot6B;
arrayOfButtons[0][6] = shoot7B;
arrayOfButtons[0][7] = shoot8B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[1][3] = shoot14B;
arrayOfButtons[1][4] = shoot15B;
arrayOfButtons[1][5] = shoot16B;
arrayOfButtons[1][6] = shoot17B;
arrayOfButtons[1][7] = shoot18B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
arrayOfButtons[2][3] = shoot24B;
arrayOfButtons[2][4] = shoot25B;
arrayOfButtons[2][5] = shoot26B;
arrayOfButtons[2][6] = shoot27B;
arrayOfButtons[2][7] = shoot28B;
arrayOfButtons[3][0] = shoot31B;
arrayOfButtons[3][1] = shoot32B;
arrayOfButtons[3][2] = shoot33B;
arrayOfButtons[3][3] = shoot34B;
arrayOfButtons[3][4] = shoot35B;
arrayOfButtons[3][5] = shoot36B;
arrayOfButtons[3][6] = shoot37B;
arrayOfButtons[3][7] = shoot38B;
arrayOfButtons[4][0] = shoot41B;
arrayOfButtons[4][1] = shoot42B;
arrayOfButtons[4][2] = shoot43B;
arrayOfButtons[4][3] = shoot44B;
arrayOfButtons[4][4] = shoot45B;
arrayOfButtons[4][5] = shoot46B;
arrayOfButtons[4][6] = shoot47B;
arrayOfButtons[4][7] = shoot48B;
arrayOfButtons[5][0] = shoot51B;
arrayOfButtons[5][1] = shoot52B;
arrayOfButtons[5][2] = shoot53B;
arrayOfButtons[5][3] = shoot54B;
arrayOfButtons[5][4] = shoot55B;
arrayOfButtons[5][5] = shoot56B;
arrayOfButtons[5][6] = shoot57B;
arrayOfButtons[5][7] = shoot58B;
arrayOfButtons[6][0] = shoot61B;
arrayOfButtons[6][1] = shoot62B;
arrayOfButtons[6][2] = shoot63B;
arrayOfButtons[6][3] = shoot64B;
arrayOfButtons[6][4] = shoot65B;
arrayOfButtons[6][5] = shoot66B;
arrayOfButtons[6][6] = shoot67B;
arrayOfButtons[6][7] = shoot68B;
arrayOfButtons[7][0] = shoot71B;
arrayOfButtons[7][1] = shoot72B;
arrayOfButtons[7][2] = shoot73B;
arrayOfButtons[7][3] = shoot74B;
arrayOfButtons[7][4] = shoot75B;
arrayOfButtons[7][5] = shoot76B;
arrayOfButtons[7][6] = shoot77B;
arrayOfButtons[7][7] = shoot78B;
} // end of else if
else if (n == 9)
{ // beginning of else if
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[0][3] = shoot4B;
arrayOfButtons[0][4] = shoot5B;
arrayOfButtons[0][5] = shoot6B;
arrayOfButtons[0][6] = shoot7B;
arrayOfButtons[0][7] = shoot8B;
arrayOfButtons[0][8] = shoot9B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[1][3] = shoot14B;
arrayOfButtons[1][4] = shoot15B;
arrayOfButtons[1][5] = shoot16B;
arrayOfButtons[1][6] = shoot17B;
arrayOfButtons[1][7] = shoot18B;
arrayOfButtons[1][8] = shoot19B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
arrayOfButtons[2][3] = shoot24B;
arrayOfButtons[2][4] = shoot25B;
arrayOfButtons[2][5] = shoot26B;
arrayOfButtons[2][6] = shoot27B;
arrayOfButtons[2][7] = shoot28B;
arrayOfButtons[2][8] = shoot29B;
arrayOfButtons[3][0] = shoot31B;
arrayOfButtons[3][1] = shoot32B;
arrayOfButtons[3][2] = shoot33B;
arrayOfButtons[3][3] = shoot34B;
arrayOfButtons[3][4] = shoot35B;
arrayOfButtons[3][5] = shoot36B;
arrayOfButtons[3][6] = shoot37B;
arrayOfButtons[3][7] = shoot38B;
arrayOfButtons[3][8] = shoot39B;
arrayOfButtons[4][0] = shoot41B;
arrayOfButtons[4][1] = shoot42B;
arrayOfButtons[4][2] = shoot43B;
arrayOfButtons[4][3] = shoot44B;
arrayOfButtons[4][4] = shoot45B;
arrayOfButtons[4][5] = shoot46B;
arrayOfButtons[4][6] = shoot47B;
arrayOfButtons[4][7] = shoot48B;
arrayOfButtons[4][8] = shoot49B;
arrayOfButtons[5][0] = shoot51B;
arrayOfButtons[5][1] = shoot52B;
arrayOfButtons[5][2] = shoot53B;
arrayOfButtons[5][3] = shoot54B;
arrayOfButtons[5][4] = shoot55B;
arrayOfButtons[5][5] = shoot56B;
arrayOfButtons[5][6] = shoot57B;
arrayOfButtons[5][7] = shoot58B;
arrayOfButtons[5][8] = shoot59B;
arrayOfButtons[6][0] = shoot61B;
arrayOfButtons[6][1] = shoot62B;
arrayOfButtons[6][2] = shoot63B;
arrayOfButtons[6][3] = shoot64B;
arrayOfButtons[6][4] = shoot65B;
arrayOfButtons[6][5] = shoot66B;
arrayOfButtons[6][6] = shoot67B;
arrayOfButtons[6][7] = shoot68B;
arrayOfButtons[6][8] = shoot69B;
arrayOfButtons[7][0] = shoot71B;
arrayOfButtons[7][1] = shoot72B;
arrayOfButtons[7][2] = shoot73B;
arrayOfButtons[7][3] = shoot74B;
arrayOfButtons[7][4] = shoot75B;
arrayOfButtons[7][5] = shoot76B;
arrayOfButtons[7][6] = shoot77B;
arrayOfButtons[7][7] = shoot78B;
arrayOfButtons[7][8] = shoot79B;
arrayOfButtons[8][0] = shoot81B;
arrayOfButtons[8][1] = shoot82B;
arrayOfButtons[8][2] = shoot83B;
arrayOfButtons[8][3] = shoot84B;
arrayOfButtons[8][4] = shoot85B;
arrayOfButtons[8][5] = shoot86B;
arrayOfButtons[8][6] = shoot87B;
arrayOfButtons[8][7] = shoot88B;
arrayOfButtons[8][8] = shoot89B;
} // end of else if
else
{ // beginning of else
arrayOfButtons[0][0] = shoot1B;
arrayOfButtons[0][1] = shoot2B;
arrayOfButtons[0][2] = shoot3B;
arrayOfButtons[0][3] = shoot4B;
arrayOfButtons[0][4] = shoot5B;
arrayOfButtons[0][5] = shoot6B;
arrayOfButtons[0][6] = shoot7B;
arrayOfButtons[0][7] = shoot8B;
arrayOfButtons[0][8] = shoot9B;
arrayOfButtons[0][9] = shoot10B;
arrayOfButtons[1][0] = shoot11B;
arrayOfButtons[1][1] = shoot12B;
arrayOfButtons[1][2] = shoot13B;
arrayOfButtons[1][3] = shoot14B;
arrayOfButtons[1][4] = shoot15B;
arrayOfButtons[1][5] = shoot16B;
arrayOfButtons[1][6] = shoot17B;
arrayOfButtons[1][7] = shoot18B;
arrayOfButtons[1][8] = shoot19B;
arrayOfButtons[1][9] = shoot20B;
arrayOfButtons[2][0] = shoot21B;
arrayOfButtons[2][1] = shoot22B;
arrayOfButtons[2][2] = shoot23B;
arrayOfButtons[2][3] = shoot24B;
arrayOfButtons[2][4] = shoot25B;
arrayOfButtons[2][5] = shoot26B;
arrayOfButtons[2][6] = shoot27B;
arrayOfButtons[2][7] = shoot28B;
arrayOfButtons[2][8] = shoot29B;
arrayOfButtons[2][9] = shoot30B;
arrayOfButtons[3][0] = shoot31B;
arrayOfButtons[3][1] = shoot32B;
arrayOfButtons[3][2] = shoot33B;
arrayOfButtons[3][3] = shoot34B;
arrayOfButtons[3][4] = shoot35B;
arrayOfButtons[3][5] = shoot36B;
arrayOfButtons[3][6] = shoot37B;
arrayOfButtons[3][7] = shoot38B;
arrayOfButtons[3][8] = shoot39B;
arrayOfButtons[3][9] = shoot40B;
arrayOfButtons[4][0] = shoot41B;
arrayOfButtons[4][1] = shoot42B;
arrayOfButtons[4][2] = shoot43B;
arrayOfButtons[4][3] = shoot44B;
arrayOfButtons[4][4] = shoot45B;
arrayOfButtons[4][5] = shoot46B;
arrayOfButtons[4][6] = shoot47B;
arrayOfButtons[4][7] = shoot48B;
arrayOfButtons[4][8] = shoot49B;
arrayOfButtons[4][9] = shoot50B;
arrayOfButtons[5][0] = shoot51B;
arrayOfButtons[5][1] = shoot52B;
arrayOfButtons[5][2] = shoot53B;
arrayOfButtons[5][3] = shoot54B;
arrayOfButtons[5][4] = shoot55B;
arrayOfButtons[5][5] = shoot56B;
arrayOfButtons[5][6] = shoot57B;
arrayOfButtons[5][7] = shoot58B;
arrayOfButtons[5][8] = shoot59B;
arrayOfButtons[5][9] = shoot60B;
arrayOfButtons[6][0] = shoot61B;
arrayOfButtons[6][1] = shoot62B;
arrayOfButtons[6][2] = shoot63B;
arrayOfButtons[6][3] = shoot64B;
arrayOfButtons[6][4] = shoot65B;
arrayOfButtons[6][5] = shoot66B;
arrayOfButtons[6][6] = shoot67B;
arrayOfButtons[6][7] = shoot68B;
arrayOfButtons[6][8] = shoot69B;
arrayOfButtons[6][9] = shoot70B;
arrayOfButtons[7][0] = shoot71B;
arrayOfButtons[7][1] = shoot72B;
arrayOfButtons[7][2] = shoot73B;
arrayOfButtons[7][3] = shoot74B;
arrayOfButtons[7][4] = shoot75B;
arrayOfButtons[7][5] = shoot76B;
arrayOfButtons[7][6] = shoot77B;
arrayOfButtons[7][7] = shoot78B;
arrayOfButtons[7][8] = shoot79B;
arrayOfButtons[7][9] = shoot80B;
arrayOfButtons[8][0] = shoot81B;
arrayOfButtons[8][1] = shoot82B;
arrayOfButtons[8][2] = shoot83B;
arrayOfButtons[8][3] = shoot84B;
arrayOfButtons[8][4] = shoot85B;
arrayOfButtons[8][5] = shoot86B;
arrayOfButtons[8][6] = shoot87B;
arrayOfButtons[8][7] = shoot88B;
arrayOfButtons[8][8] = shoot89B;
arrayOfButtons[8][9] = shoot90B;
arrayOfButtons[9][0] = shoot91B;
arrayOfButtons[9][1] = shoot92B;
arrayOfButtons[9][2] = shoot93B;
arrayOfButtons[9][3] = shoot94B;
arrayOfButtons[9][4] = shoot95B;
arrayOfButtons[9][5] = shoot96B;
arrayOfButtons[9][6] = shoot97B;
arrayOfButtons[9][7] = shoot98B;
arrayOfButtons[9][8] = shoot99B;
arrayOfButtons[9][9] = shoot100B;
} // end of else
} // end of if
// makes an n by n grid
if ( n == 2)
{ // beginning of if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(false);
shoot4B.setVisible(false);
shoot5B.setVisible(false);
shoot6B.setVisible(false);
shoot7B.setVisible(false);
shoot8B.setVisible(false);
shoot9B.setVisible(false);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(false);
shoot14B.setVisible(false);
shoot15B.setVisible(false);
shoot16B.setVisible(false);
shoot17B.setVisible(false);
shoot18B.setVisible(false);
shoot19B.setVisible(false);
shoot20B.setVisible(false);
shoot21B.setVisible(false);
shoot22B.setVisible(false);
shoot23B.setVisible(false);
shoot24B.setVisible(false);
shoot25B.setVisible(false);
shoot26B.setVisible(false);
shoot27B.setVisible(false);
shoot28B.setVisible(false);
shoot29B.setVisible(false);
shoot30B.setVisible(false);
shoot31B.setVisible(false);
shoot32B.setVisible(false);
shoot33B.setVisible(false);
shoot34B.setVisible(false);
shoot35B.setVisible(false);
shoot36B.setVisible(false);
shoot37B.setVisible(false);
shoot38B.setVisible(false);
shoot39B.setVisible(false);
shoot40B.setVisible(false);
shoot41B.setVisible(false);
shoot42B.setVisible(false);
shoot43B.setVisible(false);
shoot44B.setVisible(false);
shoot45B.setVisible(false);
shoot46B.setVisible(false);
shoot47B.setVisible(false);
shoot48B.setVisible(false);
shoot49B.setVisible(false);
shoot50B.setVisible(false);
shoot51B.setVisible(false);
shoot52B.setVisible(false);
shoot53B.setVisible(false);
shoot54B.setVisible(false);
shoot55B.setVisible(false);
shoot56B.setVisible(false);
shoot57B.setVisible(false);
shoot58B.setVisible(false);
shoot59B.setVisible(false);
shoot60B.setVisible(false);
shoot61B.setVisible(false);
shoot62B.setVisible(false);
shoot63B.setVisible(false);
shoot64B.setVisible(false);
shoot65B.setVisible(false);
shoot66B.setVisible(false);
shoot67B.setVisible(false);
shoot68B.setVisible(false);
shoot69B.setVisible(false);
shoot70B.setVisible(false);
shoot71B.setVisible(false);
shoot72B.setVisible(false);
shoot73B.setVisible(false);
shoot74B.setVisible(false);
shoot75B.setVisible(false);
shoot76B.setVisible(false);
shoot77B.setVisible(false);
shoot78B.setVisible(false);
shoot79B.setVisible(false);
shoot80B.setVisible(false);
shoot81B.setVisible(false);
shoot82B.setVisible(false);
shoot83B.setVisible(false);
shoot84B.setVisible(false);
shoot85B.setVisible(false);
shoot86B.setVisible(false);
shoot87B.setVisible(false);
shoot88B.setVisible(false);
shoot89B.setVisible(false);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of if
else if (n == 3)
{ // beginning of else if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(false);
shoot5B.setVisible(false);
shoot6B.setVisible(false);
shoot7B.setVisible(false);
shoot8B.setVisible(false);
shoot9B.setVisible(false);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(false);
shoot15B.setVisible(false);
shoot16B.setVisible(false);
shoot17B.setVisible(false);
shoot18B.setVisible(false);
shoot19B.setVisible(false);
shoot20B.setVisible(false);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(false);
shoot25B.setVisible(false);
shoot26B.setVisible(false);
shoot27B.setVisible(false);
shoot28B.setVisible(false);
shoot29B.setVisible(false);
shoot30B.setVisible(false);
shoot31B.setVisible(false);
shoot32B.setVisible(false);
shoot33B.setVisible(false);
shoot34B.setVisible(false);
shoot35B.setVisible(false);
shoot36B.setVisible(false);
shoot37B.setVisible(false);
shoot38B.setVisible(false);
shoot39B.setVisible(false);
shoot40B.setVisible(false);
shoot41B.setVisible(false);
shoot42B.setVisible(false);
shoot43B.setVisible(false);
shoot44B.setVisible(false);
shoot45B.setVisible(false);
shoot46B.setVisible(false);
shoot47B.setVisible(false);
shoot48B.setVisible(false);
shoot49B.setVisible(false);
shoot50B.setVisible(false);
shoot51B.setVisible(false);
shoot52B.setVisible(false);
shoot53B.setVisible(false);
shoot54B.setVisible(false);
shoot55B.setVisible(false);
shoot56B.setVisible(false);
shoot57B.setVisible(false);
shoot58B.setVisible(false);
shoot59B.setVisible(false);
shoot60B.setVisible(false);
shoot61B.setVisible(false);
shoot62B.setVisible(false);
shoot63B.setVisible(false);
shoot64B.setVisible(false);
shoot65B.setVisible(false);
shoot66B.setVisible(false);
shoot67B.setVisible(false);
shoot68B.setVisible(false);
shoot69B.setVisible(false);
shoot70B.setVisible(false);
shoot71B.setVisible(false);
shoot72B.setVisible(false);
shoot73B.setVisible(false);
shoot74B.setVisible(false);
shoot75B.setVisible(false);
shoot76B.setVisible(false);
shoot77B.setVisible(false);
shoot78B.setVisible(false);
shoot79B.setVisible(false);
shoot80B.setVisible(false);
shoot81B.setVisible(false);
shoot82B.setVisible(false);
shoot83B.setVisible(false);
shoot84B.setVisible(false);
shoot85B.setVisible(false);
shoot86B.setVisible(false);
shoot87B.setVisible(false);
shoot88B.setVisible(false);
shoot89B.setVisible(false);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of else if
else if (n == 4)
{ // beginning of else if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(true);
shoot5B.setVisible(false);
shoot6B.setVisible(false);
shoot7B.setVisible(false);
shoot8B.setVisible(false);
shoot9B.setVisible(false);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(true);
shoot15B.setVisible(false);
shoot16B.setVisible(false);
shoot17B.setVisible(false);
shoot18B.setVisible(false);
shoot19B.setVisible(false);
shoot20B.setVisible(false);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(true);
shoot25B.setVisible(false);
shoot26B.setVisible(false);
shoot27B.setVisible(false);
shoot28B.setVisible(false);
shoot29B.setVisible(false);
shoot30B.setVisible(false);
shoot31B.setVisible(true);
shoot32B.setVisible(true);
shoot33B.setVisible(true);
shoot34B.setVisible(true);
shoot35B.setVisible(false);
shoot36B.setVisible(false);
shoot37B.setVisible(false);
shoot38B.setVisible(false);
shoot39B.setVisible(false);
shoot40B.setVisible(false);
shoot41B.setVisible(false);
shoot42B.setVisible(false);
shoot43B.setVisible(false);
shoot44B.setVisible(false);
shoot45B.setVisible(false);
shoot46B.setVisible(false);
shoot47B.setVisible(false);
shoot48B.setVisible(false);
shoot49B.setVisible(false);
shoot50B.setVisible(false);
shoot51B.setVisible(false);
shoot52B.setVisible(false);
shoot53B.setVisible(false);
shoot54B.setVisible(false);
shoot55B.setVisible(false);
shoot56B.setVisible(false);
shoot57B.setVisible(false);
shoot58B.setVisible(false);
shoot59B.setVisible(false);
shoot60B.setVisible(false);
shoot61B.setVisible(false);
shoot62B.setVisible(false);
shoot63B.setVisible(false);
shoot64B.setVisible(false);
shoot65B.setVisible(false);
shoot66B.setVisible(false);
shoot67B.setVisible(false);
shoot68B.setVisible(false);
shoot69B.setVisible(false);
shoot70B.setVisible(false);
shoot71B.setVisible(false);
shoot72B.setVisible(false);
shoot73B.setVisible(false);
shoot74B.setVisible(false);
shoot75B.setVisible(false);
shoot76B.setVisible(false);
shoot77B.setVisible(false);
shoot78B.setVisible(false);
shoot79B.setVisible(false);
shoot80B.setVisible(false);
shoot81B.setVisible(false);
shoot82B.setVisible(false);
shoot83B.setVisible(false);
shoot84B.setVisible(false);
shoot85B.setVisible(false);
shoot86B.setVisible(false);
shoot87B.setVisible(false);
shoot88B.setVisible(false);
shoot89B.setVisible(false);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of else if
else if (n == 5)
{ // beginning of else if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(true);
shoot5B.setVisible(true);
shoot6B.setVisible(false);
shoot7B.setVisible(false);
shoot8B.setVisible(false);
shoot9B.setVisible(false);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(true);
shoot15B.setVisible(true);
shoot16B.setVisible(false);
shoot17B.setVisible(false);
shoot18B.setVisible(false);
shoot19B.setVisible(false);
shoot20B.setVisible(false);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(true);
shoot25B.setVisible(true);
shoot26B.setVisible(false);
shoot27B.setVisible(false);
shoot28B.setVisible(false);
shoot29B.setVisible(false);
shoot30B.setVisible(false);
shoot31B.setVisible(true);
shoot32B.setVisible(true);
shoot33B.setVisible(true);
shoot34B.setVisible(true);
shoot35B.setVisible(true);
shoot36B.setVisible(false);
shoot37B.setVisible(false);
shoot38B.setVisible(false);
shoot39B.setVisible(false);
shoot40B.setVisible(false);
shoot41B.setVisible(true);
shoot42B.setVisible(true);
shoot43B.setVisible(true);
shoot44B.setVisible(true);
shoot45B.setVisible(true);
shoot46B.setVisible(false);
shoot47B.setVisible(false);
shoot48B.setVisible(false);
shoot49B.setVisible(false);
shoot50B.setVisible(false);
shoot51B.setVisible(false);
shoot52B.setVisible(false);
shoot53B.setVisible(false);
shoot54B.setVisible(false);
shoot55B.setVisible(false);
shoot56B.setVisible(false);
shoot57B.setVisible(false);
shoot58B.setVisible(false);
shoot59B.setVisible(false);
shoot60B.setVisible(false);
shoot61B.setVisible(false);
shoot62B.setVisible(false);
shoot63B.setVisible(false);
shoot64B.setVisible(false);
shoot65B.setVisible(false);
shoot66B.setVisible(false);
shoot67B.setVisible(false);
shoot68B.setVisible(false);
shoot69B.setVisible(false);
shoot70B.setVisible(false);
shoot71B.setVisible(false);
shoot72B.setVisible(false);
shoot73B.setVisible(false);
shoot74B.setVisible(false);
shoot75B.setVisible(false);
shoot76B.setVisible(false);
shoot77B.setVisible(false);
shoot78B.setVisible(false);
shoot79B.setVisible(false);
shoot80B.setVisible(false);
shoot81B.setVisible(false);
shoot82B.setVisible(false);
shoot83B.setVisible(false);
shoot84B.setVisible(false);
shoot85B.setVisible(false);
shoot86B.setVisible(false);
shoot87B.setVisible(false);
shoot88B.setVisible(false);
shoot89B.setVisible(false);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of else if
else if (n == 6)
{ // beginning of else if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(true);
shoot5B.setVisible(true);
shoot6B.setVisible(true);
shoot7B.setVisible(false);
shoot8B.setVisible(false);
shoot9B.setVisible(false);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(true);
shoot15B.setVisible(true);
shoot16B.setVisible(true);
shoot17B.setVisible(false);
shoot18B.setVisible(false);
shoot19B.setVisible(false);
shoot20B.setVisible(false);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(true);
shoot25B.setVisible(true);
shoot26B.setVisible(true);
shoot27B.setVisible(false);
shoot28B.setVisible(false);
shoot29B.setVisible(false);
shoot30B.setVisible(false);
shoot31B.setVisible(true);
shoot32B.setVisible(true);
shoot33B.setVisible(true);
shoot34B.setVisible(true);
shoot35B.setVisible(true);
shoot36B.setVisible(true);
shoot37B.setVisible(false);
shoot38B.setVisible(false);
shoot39B.setVisible(false);
shoot40B.setVisible(false);
shoot41B.setVisible(true);
shoot42B.setVisible(true);
shoot43B.setVisible(true);
shoot44B.setVisible(true);
shoot45B.setVisible(true);
shoot46B.setVisible(true);
shoot47B.setVisible(false);
shoot48B.setVisible(false);
shoot49B.setVisible(false);
shoot50B.setVisible(false);
shoot51B.setVisible(true);
shoot52B.setVisible(true);
shoot53B.setVisible(true);
shoot54B.setVisible(true);
shoot55B.setVisible(true);
shoot56B.setVisible(true);
shoot57B.setVisible(false);
shoot58B.setVisible(false);
shoot59B.setVisible(false);
shoot60B.setVisible(false);
shoot61B.setVisible(false);
shoot62B.setVisible(false);
shoot63B.setVisible(false);
shoot64B.setVisible(false);
shoot65B.setVisible(false);
shoot66B.setVisible(false);
shoot67B.setVisible(false);
shoot68B.setVisible(false);
shoot69B.setVisible(false);
shoot70B.setVisible(false);
shoot71B.setVisible(false);
shoot72B.setVisible(false);
shoot73B.setVisible(false);
shoot74B.setVisible(false);
shoot75B.setVisible(false);
shoot76B.setVisible(false);
shoot77B.setVisible(false);
shoot78B.setVisible(false);
shoot79B.setVisible(false);
shoot80B.setVisible(false);
shoot81B.setVisible(false);
shoot82B.setVisible(false);
shoot83B.setVisible(false);
shoot84B.setVisible(false);
shoot85B.setVisible(false);
shoot86B.setVisible(false);
shoot87B.setVisible(false);
shoot88B.setVisible(false);
shoot89B.setVisible(false);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of else if
else if (n == 7)
{ // beginning of else if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(true);
shoot5B.setVisible(true);
shoot6B.setVisible(true);
shoot7B.setVisible(true);
shoot8B.setVisible(false);
shoot9B.setVisible(false);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(true);
shoot15B.setVisible(true);
shoot16B.setVisible(true);
shoot17B.setVisible(true);
shoot18B.setVisible(false);
shoot19B.setVisible(false);
shoot20B.setVisible(false);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(true);
shoot25B.setVisible(true);
shoot26B.setVisible(true);
shoot27B.setVisible(true);
shoot28B.setVisible(false);
shoot29B.setVisible(false);
shoot30B.setVisible(false);
shoot31B.setVisible(true);
shoot32B.setVisible(true);
shoot33B.setVisible(true);
shoot34B.setVisible(true);
shoot35B.setVisible(true);
shoot36B.setVisible(true);
shoot37B.setVisible(true);
shoot38B.setVisible(false);
shoot39B.setVisible(false);
shoot40B.setVisible(false);
shoot41B.setVisible(true);
shoot42B.setVisible(true);
shoot43B.setVisible(true);
shoot44B.setVisible(true);
shoot45B.setVisible(true);
shoot46B.setVisible(true);
shoot47B.setVisible(true);
shoot48B.setVisible(false);
shoot49B.setVisible(false);
shoot50B.setVisible(false);
shoot51B.setVisible(true);
shoot52B.setVisible(true);
shoot53B.setVisible(true);
shoot54B.setVisible(true);
shoot55B.setVisible(true);
shoot56B.setVisible(true);
shoot57B.setVisible(true);
shoot58B.setVisible(false);
shoot59B.setVisible(false);
shoot60B.setVisible(false);
shoot61B.setVisible(true);
shoot62B.setVisible(true);
shoot63B.setVisible(true);
shoot64B.setVisible(true);
shoot65B.setVisible(true);
shoot66B.setVisible(true);
shoot67B.setVisible(true);
shoot68B.setVisible(false);
shoot69B.setVisible(false);
shoot70B.setVisible(false);
shoot71B.setVisible(false);
shoot72B.setVisible(false);
shoot73B.setVisible(false);
shoot74B.setVisible(false);
shoot75B.setVisible(false);
shoot76B.setVisible(false);
shoot77B.setVisible(false);
shoot78B.setVisible(false);
shoot79B.setVisible(false);
shoot80B.setVisible(false);
shoot81B.setVisible(false);
shoot82B.setVisible(false);
shoot83B.setVisible(false);
shoot84B.setVisible(false);
shoot85B.setVisible(false);
shoot86B.setVisible(false);
shoot87B.setVisible(false);
shoot88B.setVisible(false);
shoot89B.setVisible(false);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of else if
else if (n == 8)
{ // beginning of else if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(true);
shoot5B.setVisible(true);
shoot6B.setVisible(true);
shoot7B.setVisible(true);
shoot8B.setVisible(true);
shoot9B.setVisible(false);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(true);
shoot15B.setVisible(true);
shoot16B.setVisible(true);
shoot17B.setVisible(true);
shoot18B.setVisible(true);
shoot19B.setVisible(false);
shoot20B.setVisible(false);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(true);
shoot25B.setVisible(true);
shoot26B.setVisible(true);
shoot27B.setVisible(true);
shoot28B.setVisible(true);
shoot29B.setVisible(false);
shoot30B.setVisible(false);
shoot31B.setVisible(true);
shoot32B.setVisible(true);
shoot33B.setVisible(true);
shoot34B.setVisible(true);
shoot35B.setVisible(true);
shoot36B.setVisible(true);
shoot37B.setVisible(true);
shoot38B.setVisible(true);
shoot39B.setVisible(false);
shoot40B.setVisible(false);
shoot41B.setVisible(true);
shoot42B.setVisible(true);
shoot43B.setVisible(true);
shoot44B.setVisible(true);
shoot45B.setVisible(true);
shoot46B.setVisible(true);
shoot47B.setVisible(true);
shoot48B.setVisible(true);
shoot49B.setVisible(false);
shoot50B.setVisible(false);
shoot51B.setVisible(true);
shoot52B.setVisible(true);
shoot53B.setVisible(true);
shoot54B.setVisible(true);
shoot55B.setVisible(true);
shoot56B.setVisible(true);
shoot57B.setVisible(true);
shoot58B.setVisible(true);
shoot59B.setVisible(false);
shoot60B.setVisible(false);
shoot61B.setVisible(true);
shoot62B.setVisible(true);
shoot63B.setVisible(true);
shoot64B.setVisible(true);
shoot65B.setVisible(true);
shoot66B.setVisible(true);
shoot67B.setVisible(true);
shoot68B.setVisible(true);
shoot69B.setVisible(false);
shoot70B.setVisible(false);
shoot71B.setVisible(true);
shoot72B.setVisible(true);
shoot73B.setVisible(true);
shoot74B.setVisible(true);
shoot75B.setVisible(true);
shoot76B.setVisible(true);
shoot77B.setVisible(true);
shoot78B.setVisible(true);
shoot79B.setVisible(false);
shoot80B.setVisible(false);
shoot81B.setVisible(false);
shoot82B.setVisible(false);
shoot83B.setVisible(false);
shoot84B.setVisible(false);
shoot85B.setVisible(false);
shoot86B.setVisible(false);
shoot87B.setVisible(false);
shoot88B.setVisible(false);
shoot89B.setVisible(false);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of else if
else if (n == 9)
{ // beginning of else if
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(true);
shoot5B.setVisible(true);
shoot6B.setVisible(true);
shoot7B.setVisible(true);
shoot8B.setVisible(true);
shoot9B.setVisible(true);
shoot10B.setVisible(false);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(true);
shoot15B.setVisible(true);
shoot16B.setVisible(true);
shoot17B.setVisible(true);
shoot18B.setVisible(true);
shoot19B.setVisible(true);
shoot20B.setVisible(false);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(true);
shoot25B.setVisible(true);
shoot26B.setVisible(true);
shoot27B.setVisible(true);
shoot28B.setVisible(true);
shoot29B.setVisible(true);
shoot30B.setVisible(false);
shoot31B.setVisible(true);
shoot32B.setVisible(true);
shoot33B.setVisible(true);
shoot34B.setVisible(true);
shoot35B.setVisible(true);
shoot36B.setVisible(true);
shoot37B.setVisible(true);
shoot38B.setVisible(true);
shoot39B.setVisible(true);
shoot40B.setVisible(false);
shoot41B.setVisible(true);
shoot42B.setVisible(true);
shoot43B.setVisible(true);
shoot44B.setVisible(true);
shoot45B.setVisible(true);
shoot46B.setVisible(true);
shoot47B.setVisible(true);
shoot48B.setVisible(true);
shoot49B.setVisible(true);
shoot50B.setVisible(false);
shoot51B.setVisible(true);
shoot52B.setVisible(true);
shoot53B.setVisible(true);
shoot54B.setVisible(true);
shoot55B.setVisible(true);
shoot56B.setVisible(true);
shoot57B.setVisible(true);
shoot58B.setVisible(true);
shoot59B.setVisible(true);
shoot60B.setVisible(false);
shoot61B.setVisible(true);
shoot62B.setVisible(true);
shoot63B.setVisible(true);
shoot64B.setVisible(true);
shoot65B.setVisible(true);
shoot66B.setVisible(true);
shoot67B.setVisible(true);
shoot68B.setVisible(true);
shoot69B.setVisible(true);
shoot70B.setVisible(false);
shoot71B.setVisible(true);
shoot72B.setVisible(true);
shoot73B.setVisible(true);
shoot74B.setVisible(true);
shoot75B.setVisible(true);
shoot76B.setVisible(true);
shoot77B.setVisible(true);
shoot78B.setVisible(true);
shoot79B.setVisible(true);
shoot80B.setVisible(false);
shoot81B.setVisible(true);
shoot82B.setVisible(true);
shoot83B.setVisible(true);
shoot84B.setVisible(true);
shoot85B.setVisible(true);
shoot86B.setVisible(true);
shoot87B.setVisible(true);
shoot88B.setVisible(true);
shoot89B.setVisible(true);
shoot90B.setVisible(false);
shoot91B.setVisible(false);
shoot92B.setVisible(false);
shoot93B.setVisible(false);
shoot94B.setVisible(false);
shoot95B.setVisible(false);
shoot96B.setVisible(false);
shoot97B.setVisible(false);
shoot98B.setVisible(false);
shoot99B.setVisible(false);
shoot100B.setVisible(false);
} // end of else if
else
{ // beginning of else
shoot1B.setVisible(true);
shoot2B.setVisible(true);
shoot3B.setVisible(true);
shoot4B.setVisible(true);
shoot5B.setVisible(true);
shoot6B.setVisible(true);
shoot7B.setVisible(true);
shoot8B.setVisible(true);
shoot9B.setVisible(true);
shoot10B.setVisible(true);
shoot11B.setVisible(true);
shoot12B.setVisible(true);
shoot13B.setVisible(true);
shoot14B.setVisible(true);
shoot15B.setVisible(true);
shoot16B.setVisible(true);
shoot17B.setVisible(true);
shoot18B.setVisible(true);
shoot19B.setVisible(true);
shoot20B.setVisible(true);
shoot21B.setVisible(true);
shoot22B.setVisible(true);
shoot23B.setVisible(true);
shoot24B.setVisible(true);
shoot25B.setVisible(true);
shoot26B.setVisible(true);
shoot27B.setVisible(true);
shoot28B.setVisible(true);
shoot29B.setVisible(true);
shoot30B.setVisible(true);
shoot31B.setVisible(true);
shoot32B.setVisible(true);
shoot33B.setVisible(true);
shoot34B.setVisible(true);
shoot35B.setVisible(true);
shoot36B.setVisible(true);
shoot37B.setVisible(true);
shoot38B.setVisible(true);
shoot39B.setVisible(true);
shoot40B.setVisible(true);
shoot41B.setVisible(true);
shoot42B.setVisible(true);
shoot43B.setVisible(true);
shoot44B.setVisible(true);
shoot45B.setVisible(true);
shoot46B.setVisible(true);
shoot47B.setVisible(true);
shoot48B.setVisible(true);
shoot49B.setVisible(true);
shoot50B.setVisible(true);
shoot51B.setVisible(true);
shoot52B.setVisible(true);
shoot53B.setVisible(true);
shoot54B.setVisible(true);
shoot55B.setVisible(true);
shoot56B.setVisible(true);
shoot57B.setVisible(true);
shoot58B.setVisible(true);
shoot59B.setVisible(true);
shoot60B.setVisible(true);
shoot61B.setVisible(true);
shoot62B.setVisible(true);
shoot63B.setVisible(true);
shoot64B.setVisible(true);
shoot65B.setVisible(true);
shoot66B.setVisible(true);
shoot67B.setVisible(true);
shoot68B.setVisible(true);
shoot69B.setVisible(true);
shoot70B.setVisible(true);
shoot71B.setVisible(true);
shoot72B.setVisible(true);
shoot73B.setVisible(true);
shoot74B.setVisible(true);
shoot75B.setVisible(true);
shoot76B.setVisible(true);
shoot77B.setVisible(true);
shoot78B.setVisible(true);
shoot79B.setVisible(true);
shoot80B.setVisible(true);
shoot81B.setVisible(true);
shoot82B.setVisible(true);
shoot83B.setVisible(true);
shoot84B.setVisible(true);
shoot85B.setVisible(true);
shoot86B.setVisible(true);
shoot87B.setVisible(true);
shoot88B.setVisible(true);
shoot89B.setVisible(true);
shoot90B.setVisible(true);
shoot91B.setVisible(true);
shoot92B.setVisible(true);
shoot93B.setVisible(true);
shoot94B.setVisible(true);
shoot95B.setVisible(true);
shoot96B.setVisible(true);
shoot97B.setVisible(true);
shoot98B.setVisible(true);
shoot99B.setVisible(true);
shoot100B.setVisible(true);
} // end of else
quitB.setSize(80, 30);
setSize(WIDTH, HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
} // end of constructor
public static void main(String[] args)
{ // beginning of main
BattleshipGUI refVar = new BattleshipGUI();
} // end of main
// this method handles the buttons.
public void actionPerformed(ActionEvent e)
{ // beginning of method
String outputStr2, outputStr3, outputStr4, outputStr5, outputStr6;
String outputStrM, outputStrA, outputStrAA;
outputStrM = "Miss";
outputStrA = "Already shot there";
outputStrAA = "I told you that you already shot there";
outputStr2 = "Are you sure you want to quit? ";
outputStr3 = "You Quit.";
outputStr4 = "Ok don't quit then." ;
outputStr5 = "Thought not.";
outputStr6 = "You surrendered.";
int i, j, x,y;
x = 0;
i = 0;
y = 0;
j = 0;
int v;
v = 0;
IntClass getN;
int shots = Integer.parseInt(shotsTF.getText());
int w = Integer.parseInt(arraySizeTF.getText());
placeBattleship(charArray);
int num, num2;
num = 0;
num2 = 0;
Integer tries;
Integer tries2;
Integer tries3;
Integer tries4;
tries = shots;
tries2 = shots;
tries3 = shots;
tries4 = shots;
if (e.getActionCommand().equals("Quit"))
{ // beginning of if
Object[] options = {"Yes",
"Continue Playing"};
int n = JOptionPane.showOptionDialog(frame,
"Are you sure you want to Quit?",
"Quit",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, options, options[0]);
// creates Yes and Continue playing butons buttons.
// if Yee button is clicked, sends output "You quit." as heading and sends a message "Adiós!" and exits when
// user clicks OK on dialog box
if (n == JOptionPane.YES_OPTION)
{ // beginning of if
JOptionPane.showMessageDialog(null,"Adiós!", outputStr3, JOptionPane.PLAIN_MESSAGE);
System.exit(0);
} // end of if
// changes the string the standard dialog box for the No button but still uses its predefined return value. If user clicks on
// Continue Playing, sends title "Ok don't quit then." and the message "Whatever." and takes the user back to the grid.
else if (n == JOptionPane.NO_OPTION)
{ // beginning of else if
JOptionPane.showMessageDialog(null,"Whatever.", outputStr4, JOptionPane.PLAIN_MESSAGE);
} // end of else if
} // end of if
else if (e.getActionCommand().equals("Surrender"))
{ // beginning of else if
shots = shots + 1;
Object[] options2 = {"Yes",
"No, I have not yet begun to fight!"};
int p = JOptionPane.showOptionDialog(frame,
"Are you sure you want to Surrender?",
"Surrender?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, options2, options2[0]);
// creates Yes and No, I have not yet begun to fight! butons .
// if Yes button is clicked, sends output "You surrendered." as heading and sends a message "It took you [number of shots]
// shots!" and exits when user clicks OK on dialog box
if (p == JOptionPane.YES_OPTION)
{ // beginning of if
// code for showing grid
arrayOfButtons[i][j].setText("B");
JOptionPane.showMessageDialog(null, "You took " + shotsTF.getText() + " shots" , outputStr6, JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
} // end of if
// changes the string the standard dialog box for the No button but still uses its predefined return value. If user clicks on
// "No button", sends output "Thought not." and the title "You didn't surrender." and takes the user back to the grid.
else if (p == JOptionPane.NO_OPTION)
{ // beginning of else if
JOptionPane.showMessageDialog(null, outputStr5, "You didn't surrender." , JOptionPane.PLAIN_MESSAGE);
} // end of else if
} // end of else if
else if (e.getActionCommand().equals("0"))
{ // beginning of else if
int K;
int t;
String r;
// I tried with the shots. This assignment is very difficult.
if ( Fire(charArray, x, y) == 'H')
{ // beginning of if
String outputStr7;
arrayOfButtons[i][j].setText("H"); // changes text on button to H
shots = shots + 1;
tries = new Integer(shots);
shotsTF.setText(tries.toString());
outputStr7 = "You sank my battleship. " + "\n" + "You sank my battleship in" + shotsTF.getText() + "tries";
JOptionPane.showMessageDialog(null, outputStr7 , "You win!", + JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}// end of if
else
{ // beginning of else
JOptionPane.showMessageDialog(null, outputStrM , "You missed!", + JOptionPane.INFORMATION_MESSAGE);
arrayOfButtons[i][j].setText("M"); // changes text on button to M
shots = shots + 1;
tries2 = new Integer(shots);
shotsTF.setText(tries2.toString());
} // end of else
} // end of else if
// does this if text on button hit is M.
else if (e.getActionCommand().equals("M"))
{ // beginning of else if
shots = shots + 1;
tries3 = new Integer(shots);
shotsTF.setText(tries3.toString());
JOptionPane.showMessageDialog(null, outputStrA , "Still a miss!", + JOptionPane.INFORMATION_MESSAGE);
arrayOfButtons[i][j].setText("A"); // changes text on button to A
} // end of else if
// does this if text on button hit is A
else if (e.getActionCommand().equals("A"))
{ // beginning of else if
shots = shots + 1;
tries4 = new Integer(shots);
shotsTF.setText(tries4.toString());
JOptionPane.showMessageDialog(null, outputStrAA , "Still a miss!", + JOptionPane.INFORMATION_MESSAGE);
arrayOfButtons[i][j].setText("A"); // changes text, sorta, on button to A
} // end of else if
} // end of method
// the method placeBattleship, places the battleship by randomly choosing a
// row and column coordinate and storing a 'B' there. The 'B' is not displayed to
// the user unless the user hits the surrender button. It takes the array as a parameter and
// should return nothing. This method sets the location of the battleship.
private static void placeBattleship(char charArray[][])
{
int valueOne, valueTwo;
char B;
valueOne= (int) ( 1 + (Math.random() * charArray.length - 1 ));
valueTwo = (int) ( 1 + (Math.random() * charArray.length - 1));
charArray[valueOne][valueTwo] = 'B';
} //end of method placeBattleship
public static char Fire(char charArray[][], int x, int y)
{ // beginning of method Fire
char A;
char M;
char H;
// IntClass intShotObj = new IntClass(0); this would be necessary if I needed to use IntClass
// to somehow get the value of shots for Miss and Already Shot.
// IntClass intShotObj2 = new IntClass();
if (charArray[x][y] == 'B') // if battleship is hit return H and end game
{ // beginning of if statement
charArray[x][y] = 'H';
return ('H');
} // end of if statement
else if (charArray[x][y] == 'M') // this is else if
// because it could also
// be just a miss.
{ // beginning of else if statement
charArray[x][y] = 'A';
return ('A');
} // end of else if statement
else if (charArray[x][y] == 'A') // makes sure it won't set an A to an M again.
{ // beginning of else if
charArray[x][y] = 'A';
// intShotObj.addToNum(1); This would be used to add one to get
// intShotObj to get from its original value and keep adding one to it till
// I hit the battleship. I still don't know how to do that, but I found a better way.
return ('A');
} // end of else if
else
{ // beginning of else statement
charArray[x][y] = 'M';
return ('M');
} // end of else statement
} // end of method fire
} // end of program