Browse Source

Update Methode void BuildGui and class NewGameListener

main
Thoumi Ngonga Brice 2 years ago
parent
commit
e223b3f99f
  1. 21
      src/main/java/BattleShip/BShip.java

21
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;
}
}
}
Loading…
Cancel
Save