Skip to content

a4ojha/Battleship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Battleship!

Description

This is an in-console Java implementation of the classic Battleship game, played between the user and CPU. I created this project to practice OOP (object oriented programming) through the use of inheritance and polymorphism. For future updates I hope to implement a drowned ship detection system, and an overall better looking UI.

Instructions

Ensure Java is installed on your device (install here) and run the following commands:

git clone https://github.com/a4ojha/Battleship
cd Battleship
javac main.java
java main.java

Rules

You will be given 5 ships:

  • Aircraft Carrier (5 squares)

  • Crusier (3 Squares)

  • Destroyer (2 Squares)

  • 2 Boats (1 Square)

These ships will be randomly assigned a position on the 10x10 grid that is printed to the console.

In this game, you will be playing against the computer in a game of battleship:

Key:

  • O = empty spot
  • X = alive ship
  • ■ = hit ship
  • / = misfire

You and the computer will take turns firing shots at each other's grid, without seeing each other's ship placement. With each turn, you will enter the coordinates for where you want to attack, and your opponent will shoot at a random spot on your grid.

The goal is to destroy all 5 of your opponent's ships!

Once either you or the CPU wins, both boards will be displayed to reveal possible leftover ships of your opponent. Good luck and have fun!

About

Battleship game between user and CPU

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages