From 48ff5b4fce43e55b88dc4acd77533fcbed01deae Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Mon, 6 Feb 2023 20:49:05 +0100 Subject: [PATCH] Add some Implementation Methode to AIGridGUI --- src/main/java/BattleShip/AIGridGUI.java | 64 +++++++++++++++++++++++++ team.md | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index 1e9c686..cb1b9a4 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -1,6 +1,70 @@ package BattleShip; + import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; +import java.util.ArrayList; +import java.util.*; public class AIGridGUI extends JPanel { + ArrayList buttons = new ArrayList(); + ArrayList allShips = new ArrayList(); + // public ArrayList listeners = new ArrayList(); + + int[] testLocations; + int numOfGuesses = 0; + public String text; + int rows; + int columns; + boolean endGame = false; + boolean[] cellsGuessed; + boolean[] cellsHit; + boolean[] cellsKilled; + boolean randomGuess = true; + int f; // it is the first + Color Red = new Color(100, 0, 0); // + Border loweredBevel = BorderFactory.createLoweredBevelBorder(); + Border defaultBorder; + Ship shipToPlace; + boolean vertical = false; + boolean clear; + boolean shipsPlaced = false; + Ship destroyer = new Ship(2, "destroyer"); + Ship cruiser = new Ship(3, "cruiser"); + Ship submarine = new Ship(3, "submarine"); + Ship battleship = new Ship(4, "battleship"); + Ship aircraftCarrier = new Ship(5, "aircraft carrier"); + ArrayList directions = new ArrayList(); + Direction up = new Direction(); + Direction down = new Direction(); + Direction right = new Direction(); + Direction left = new Direction(); + + public AIGridGUI(int r, int c) { + + rows = r; + columns = c; + + //Create arrays to keep track of which cells have been guessed, hit, and killed/sunk. + + cellsGuessed = new boolean[(rows * columns)]; + cellsHit = new boolean[(rows * columns)]; + cellsKilled = new boolean[(rows * columns)]; + for(int i = 0; i < (rows * columns); i++) { + cellsGuessed[i] = false; + cellsHit[i] = false; + cellsKilled[i] = false; + } + + //Add all ships to an ArrayList to allow for cycling through all ships. + + allShips.add(destroyer); + allShips.add(cruiser); + allShips.add(submarine); + allShips.add(battleship); + allShips.add(aircraftCarrier); + + + } } diff --git a/team.md b/team.md index 969138d..5690043 100644 --- a/team.md +++ b/team.md @@ -1,4 +1,4 @@ - Berkan Sarp, fdai4616 - Justin Senn, fdai7107 - Eren Esen, fdai4581 -- \ No newline at end of file +- Brice Tchoumi, fdai6138 \ No newline at end of file