- This is a console-based implementation of the classic game Battleship with an improved CLI graphics system.
- The final project of Marathon "Practice for beginners" in Java by Nail Alishev
- Stack: Java, Gradle
- Task
You will need to have Java 8+ and Gradle installed on your computer to run this game.
- Clone or download this repository to your local machine.
- Navigate to the project directory.
- Compile the
Interface.java
file by running the command javacMain.java
in the terminal. - Run the game by entering the command
java Main
in the terminal.
- Each player has a battlefield represented by a 10x10 grid (default) on which he places 10 ships, hidden from his opponent.
- The goal of the game is to sink all the opposing ships! A ship is sunk when it is hit once for each space it occupies.
- In other words, a submarine, which occupies two spaces, is sunk after being hit twice.
To place a ship you need to enter a departure coordinate (1.1-10.10 for the default 10x10 board) and a direction (vertical or horizontal).
- For example: "1" and '6' or "5" and '8'.
Ships shall not overlap or be adjacent and shall remain within the boundaries of the edge.
![image](https://private-user-images.githubusercontent.com/99817031/241569778-0017fb5f-a342-47ca-85dd-2d097a7f41be.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4MzUzMTQsIm5iZiI6MTczODgzNTAxNCwicGF0aCI6Ii85OTgxNzAzMS8yNDE1Njk3NzgtMDAxN2ZiNWYtYTM0Mi00N2NhLTg1ZGQtMmQwOTdhN2Y0MWJlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDA5NDMzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU1ZTYxZTkzYWFmNTdjYjFhMTBlZjA1ZGY0MmNmNzMxZjRmMGI4ZGZmZjNlMzZkNjk4Y2Y3Y2JlMjc4NzE4MjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.L5_M7UzD0sdyVpZqjEi72V-gqDzanHlvV4N6svhUVHQ)
Once both players have configured their ships, the battle may have started!
- Shoot your opponent’s ships by matching the coordinates.
- You will be informed if you have hit or missed a ship.
- Sink all 10 another player ships to win!
![image](https://private-user-images.githubusercontent.com/99817031/241570247-11ca0b8e-e3e9-4ebb-b476-25bccb4de889.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4MzUzMTQsIm5iZiI6MTczODgzNTAxNCwicGF0aCI6Ii85OTgxNzAzMS8yNDE1NzAyNDctMTFjYTBiOGUtZTNlOS00ZWJiLWI0NzYtMjViY2NiNGRlODg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDA5NDMzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNjOWJmYTZjNThjMzU4ZWZkMzk4OTdkMmViYzY2ZTljZDlkM2U4YzdkMTBlYmYxZjdiYzc4MjU2MjNiYWQ4MzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.mJzKjUFluqMK0pLXshhINS6eG5hvaaB2pwt6z0MvFWU)
If all the ships of one of the players are destroyed, the game ends.
![image](https://private-user-images.githubusercontent.com/99817031/241570367-c884cae5-fc34-43c4-a801-c43968573edd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4MzUzMTQsIm5iZiI6MTczODgzNTAxNCwicGF0aCI6Ii85OTgxNzAzMS8yNDE1NzAzNjctYzg4NGNhZTUtZmMzNC00M2M0LWE4MDEtYzQzOTY4NTczZWRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDA5NDMzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgyMGYwNTIxMjRlOThjOGQ0OGEyYTM4YzE4ZjRlZDYyMTczMjlmMjQ5NDAzNWE2OGIwMDQzNDE1Y2Q0MGU3ZjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.7p8etczHvfliottXPsCA77pBLRvIFBHKxk66usdUi78)