Battleships (or Sea Battle) is a guessing game for two players.
It is played with grids on which the players' fleets of ships are marked. The locations of the fleet are concealed from the other player. Players take alternate turns calling "shots" at the other player's ships, and the objective of the game is to destroy the opposing player's fleet first.
The grids are typically square – usually 10×10 – and the individual squares in the grid are identified by letter and number. On a defensive grid, the player arranges their ships and records the shots made by the opponent, informing the opponent if it is a "miss" or a "hit". On the offensive grid, the player records the misses and hits.
Make a one-player version of the game where the ships are randomly positioned. The computer plays as the second player and just makes random moves, it doesn't necessarily make "smart" moves.
What you must know in order to complete the project
- Selection (if statements)
- Arrays (2-dimensional)
- How to generate a random number
- How to get user input (Scanner)
It is a good challenge for beginners, and could be tackled after doing a game like Tic Tac Toe.