Please enable JavaScript to use CodeHS

  • Autograded

Battleship

In this project, students use Object Oriented design to implement the board game Battleship.

Hard

35 Hours

High School

Project Description

Background

Battleship is a classic game that uses a basic 2D grid. The game pieces are placed in various cells of the grid to map out their locations. Players take turns finding each other’s game pieces by strategically guessing what cells are occupied by a piece on their opponent’s grid.


Your Task

In this project, you’ll learn about 2D arrays and classes by creating a Battleship program. Through a series of lessons, the game will be broken down into segments to help implement the solution.


Using Java, you’ll create your program using classes for ships (game pieces), the grid, and locations of ships within the grid. You’ll also create a class to control player interactions. To expand your game, some additional ideas are provided, such as adding messages to be displayed when a player has successfully sunk a battleship.

Project Demo

Explore this program before assigning it!