BattleShip game === ## Language: Java ## Author: written by Le The Hoang Hai --- Check out: [my github](https://github.com/hoanghailethe) ### How you can start - Clone this Repository - Go to GameBattleShip which has the main method >> run GameBattleship ### Game flow: 1. Create three ships location randomly. Each ship is three-cell length 2. If the ship crashed when creating, recreate. 3. Player guess a cell each round -> return 'hit' or 'miss' 4. Game end after all three ships'cells are hit. Return number of guesses to win. ### Demo view **Game starts** ``` WELCOME TO THE BATTLESHIPS WAR. You have to Destroy 3 ships to win |0||1||2||3||4||5||6| Y |0||-||-||-||-||-||-||-| |1||-||-||-||-||-||-||-| |2||-||-||-||-||-||-||-| |3||-||-||-||-||-||-||-| |4||-||-||-||-||-||-||-| |5||-||-||-||-||-||-||-| |6||-||-||-||-||-||-||-| X ``` **While playing** ``` Next ROUND... READY?! This is your 7's shoot... GO Log in Location XY to FIRE: 41 HIT |0||1||2||3||4||5||6| Y |0||-||-||-||-||-||-||-| |1||-||M||-||-||M||-||-| |2||-||H||M||-||-||-||-| |3||-||H||-||-||-||-||-| |4||-||H||-||M||-||-||-| |5||-||-||-||-||-||-||-| |6||-||-||-||-||-||-||-| X You have shoot 7 times Great! you've Terminated NAPOLEONSHIP ``` **And conquere** ``` 42 HIT |0||1||2||3||4||5||6| Y |0||M||-||-||M||H||H||H| |1||-||M||-||-||M||-||M| |2||-||H||M||-||-||M||-| |3||-||H||H||-||M||-||-| |4||M||H||H||M||-||M||M| |5||-||-||H||M||M||M||-| |6||-||-||M||M||M||-||-| X You have shoot 30 times Great! you've Terminated ANGELASHIP Great! you've Terminated HITLERSHIP Great! you've Terminated NAPOLEONSHIP Next ROUND... READY?! YOU DESTROYED ALL SHIPS! CONGRAT you win after 30 attempts ``` **If you want to cheat** uncomment this code and all the location of the ship will be printed out before the game start ```java public Ship () { createRandomLocation(); // System.out.println("A new ship is created"); // for (int [] arr : this.shipLocation) { // System.out.println(Arrays.toString(arr)); } ``` like this: ``` A new ship is created [2, 2] [2, 3] [2, 4] A new ship is created [5, 1] [5, 2] [5, 3] Angela is created Hitler is created ``` There maybe more than 3 ships but take the last three result. The ships crashed are eliminated