diff --git a/src/main/java/BattleShip/BShip.java b/src/main/java/BattleShip/BShip.java index 772e89d..57d1df7 100644 --- a/src/main/java/BattleShip/BShip.java +++ b/src/main/java/BattleShip/BShip.java @@ -12,11 +12,13 @@ public class BShip { JPanel textPanel = new JPanel(); JTextArea textArea = new JTextArea(); JFrame theFrame = new JFrame("Battleship"); + public boolean autoPlacement = false; JMenuItem auto; JMenuItem[] boardSize = new JMenuItem[3]; public AIGridGUI grid2; int rows = 10; int columns = 10; + boolean shipsPlaced = false; public void startGame() { @@ -28,6 +30,16 @@ public class BShip { grid2 = new AIGridGUI(rows, columns); buildGUI(); + + //Place ships on grid 2. + + if(autoPlacement) { + grid2.autoPlaceShips(); + } else { + grid2.placeShips(); + } + + //.. } public void buildGUI() { @@ -78,7 +90,14 @@ public class BShip { } public class NewGameListener implements ActionListener { - public void actionPerformed(ActionEvent a) {} + public void actionPerformed(ActionEvent a) { + + thePanel.remove(grid1); + thePanel.remove(grid2); + grid1 = null; + grid2 = null; + shipsPlaced = false; + } } }